mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-13 12:23:47 +03:00
24 lines
506 B
Python
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: ...
|