From 26f366da2f5a7e35ea1fc87eff5c5ba9fb7f44d5 Mon Sep 17 00:00:00 2001 From: Stanislav Kiriukhin Date: Sun, 13 Oct 2024 12:23:17 +0400 Subject: [PATCH] update type annotations for the constructor parameters of Factory/Singleton --- tests/tricky_cases/test_falsy_instances.py | 2 +- that_depends/providers/factories.py | 2 +- that_depends/providers/singleton.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/tricky_cases/test_falsy_instances.py b/tests/tricky_cases/test_falsy_instances.py index 5d98e55f..c0f453ca 100644 --- a/tests/tricky_cases/test_falsy_instances.py +++ b/tests/tricky_cases/test_falsy_instances.py @@ -20,7 +20,7 @@ async def create_async_resource() -> typing.AsyncIterator[dict[str, typing.Any]] class TrickyDIContainer(BaseContainer): - singleton = providers.Singleton(list) + singleton = providers.Singleton(list[object]) sync_resource = providers.Resource(create_sync_resource) async_resource = providers.Resource(create_async_resource) diff --git a/that_depends/providers/factories.py b/that_depends/providers/factories.py index a4370c41..a3a10944 100644 --- a/that_depends/providers/factories.py +++ b/that_depends/providers/factories.py @@ -10,7 +10,7 @@ class Factory(AbstractFactory[T_co]): __slots__ = "_factory", "_args", "_kwargs", "_override" - def __init__(self, factory: type[T_co] | typing.Callable[P, T_co], *args: P.args, **kwargs: P.kwargs) -> None: + def __init__(self, factory: typing.Callable[P, T_co], *args: P.args, **kwargs: P.kwargs) -> None: super().__init__() self._factory: typing.Final = factory self._args: typing.Final = args diff --git a/that_depends/providers/singleton.py b/that_depends/providers/singleton.py index d1d2a343..3b62895b 100644 --- a/that_depends/providers/singleton.py +++ b/that_depends/providers/singleton.py @@ -11,7 +11,7 @@ class Singleton(AbstractProvider[T_co]): __slots__ = "_factory", "_args", "_kwargs", "_override", "_instance", "_resolving_lock" - def __init__(self, factory: type[T_co] | typing.Callable[P, T_co], *args: P.args, **kwargs: P.kwargs) -> None: + def __init__(self, factory: typing.Callable[P, T_co], *args: P.args, **kwargs: P.kwargs) -> None: super().__init__() self._factory: typing.Final = factory self._args: typing.Final = args