from typing import Any, Protocol, Self

from cancel_contexts.exceptions import BaseCancelContextError


class ContextProtocol(Protocol):
    exception: type[BaseCancelContextError]

    def __enter__(self) -> Self: ...
    def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: ...
    def __bool__(self) -> bool: ...
    def cancel(self) -> None: ...
    def check_cancelled(self, msg: str | None = None) -> None: ...
    @property
    def cancelled(self) -> bool: ...
