"""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.""" ...