PR Title Check / check-title (pull_request) Successful in 7s
Test Python Package / unit-tests (pull_request) Successful in 9s
Code Quality Pipeline / code-quality (pull_request) Successful in 22s
Test Python Package / integration-tests (pull_request) Successful in 24s
Test Python Package / coverage-report (pull_request) Successful in 8s
Enables structural subtyping for consumers while preserving nominal adapter inheritance, instantiation guards, and scan_keys defaults. Co-authored-by: Cursor <[email protected]>
24 lines
595 B
Python
24 lines
595 B
Python
"""Definition of ContextAwareInterface protocol and abstract base class."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from abc import abstractmethod
|
|
from typing import Protocol, Self, runtime_checkable
|
|
|
|
|
|
@runtime_checkable
|
|
class ContextAwareInterface(Protocol):
|
|
"""Interface that defines context-related methods."""
|
|
|
|
@abstractmethod
|
|
def __enter__(self) -> Self:
|
|
"""Enter the context."""
|
|
...
|
|
|
|
@abstractmethod
|
|
def __exit__(
|
|
self, exc_type: type | None, exc_val: object | None, exc_tb: object | None
|
|
) -> None:
|
|
"""Exit the context."""
|
|
...
|