Files
python-repositories/python_repositories/interfaces/context_aware_interface.py
T
Brian Bjarke JensenandCursor 497533f0e3
Code Quality Pipeline / code-quality (pull_request) Failing after 26s
Test Python Package / test (pull_request) Successful in 1m7s
Fix mypy context manager typing for adapter subclasses.
Return Self from __enter__ so with-blocks preserve subclass types, and align mypy python_version with the 3.12 runtime target.

Co-authored-by: Cursor <[email protected]>
2026-06-28 19:42:15 +02:00

23 lines
534 B
Python

"""Definition of ContextAwareInterface abstract base class."""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Self
class ContextAwareInterface(ABC):
"""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."""
...