python-dependency-injector/src/dependency_injector/resources.py
2025-01-18 17:02:55 +00:00

24 lines
506 B
Python

"""Resources module."""
import abc
from typing import TypeVar, Generic, Optional
T = TypeVar("T")
class Resource(Generic[T], metaclass=abc.ABCMeta):
@abc.abstractmethod
def init(self, *args, **kwargs) -> Optional[T]: ...
def shutdown(self, resource: Optional[T]) -> None: ...
class AsyncResource(Generic[T], metaclass=abc.ABCMeta):
@abc.abstractmethod
async def init(self, *args, **kwargs) -> Optional[T]: ...
async def shutdown(self, resource: Optional[T]) -> None: ...