Source code for interactions.utils.abc.base_context_managers
from abc import ABC, abstractmethod
from typing import TypeVar
_T = TypeVar("_T")
__all__ = ("BaseAsyncContextManager", "BaseContextManager")
[docs]class BaseAsyncContextManager(ABC):
"""
.. versionadded:: 4.3.2
A base class for async context managers.
"""
[docs] @abstractmethod
def __init__(self):
"""Initialise the Context manager"""
raise NotImplementedError
[docs] @abstractmethod
async def __aenter__(self):
"""Enter the context manager"""
raise NotImplementedError
[docs] @abstractmethod
async def __aexit__(self, exc_type, exc_val, exc_tb):
"""Exit the context Manager"""
raise NotImplementedError
[docs]class BaseContextManager(ABC):
"""
.. versionadded:: 4.3.2
A base class for context managers.
"""
[docs] @abstractmethod
def __init__(self):
"""Initialise the Context manager"""
raise NotImplementedError
[docs] @abstractmethod
def __enter__(self):
"""Enter the context manager"""
raise NotImplementedError
[docs] @abstractmethod
def __exit__(self, exc_type, exc_val, exc_tb):
"""Exit the context Manager"""
raise NotImplementedError