From 31976d60f14c0e2cf00bd7110f753d2b6ca8a6ef Mon Sep 17 00:00:00 2001 From: Jonathan Serafini Date: Thu, 17 Aug 2023 23:21:43 -0400 Subject: [PATCH] remove protocol --- fast_depends/dependencies/provider.py | 6 +----- fast_depends/use.py | 17 +++++------------ 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/fast_depends/dependencies/provider.py b/fast_depends/dependencies/provider.py index baf0de6..c9355d2 100644 --- a/fast_depends/dependencies/provider.py +++ b/fast_depends/dependencies/provider.py @@ -1,8 +1,4 @@ -from typing import Any, Callable, Dict, Protocol - - -class HasDependencyOverrides(Protocol): - dependency_overrides: Dict[Callable[..., Any], Callable[..., Any]] +from typing import Any, Callable, Dict class Provider: diff --git a/fast_depends/use.py b/fast_depends/use.py index 0a7d6b9..ee341dd 100644 --- a/fast_depends/use.py +++ b/fast_depends/use.py @@ -6,7 +6,6 @@ from fast_depends.core import CallModel, build_call_model from fast_depends.dependencies import dependency_provider, model -from fast_depends.dependencies.provider import HasDependencyOverrides P = ParamSpec("P") T = TypeVar("T") @@ -41,9 +40,7 @@ def __call__( def inject( # pragma: no covers func: None, *, - dependency_overrides_provider: Optional[ - HasDependencyOverrides - ] = dependency_provider, + dependency_overrides_provider: Optional[Any] = dependency_provider, extra_dependencies: Sequence[model.Depends] = (), wrap_model: Callable[[CallModel[P, T]], CallModel[P, T]] = lambda x: x, ) -> _InjectWrapper[P, T]: @@ -54,9 +51,7 @@ def inject( # pragma: no covers def inject( # pragma: no covers func: Callable[P, T], *, - dependency_overrides_provider: Optional[ - HasDependencyOverrides - ] = dependency_provider, + dependency_overrides_provider: Optional[Any] = dependency_provider, extra_dependencies: Sequence[model.Depends] = (), wrap_model: Callable[[CallModel[P, T]], CallModel[P, T]] = lambda x: x, ) -> Callable[P, T]: @@ -66,9 +61,7 @@ def inject( # pragma: no covers def inject( func: Optional[Union[Callable[P, T], Callable[P, Awaitable[T]]]] = None, *, - dependency_overrides_provider: Optional[ - HasDependencyOverrides - ] = dependency_provider, + dependency_overrides_provider: Optional[Any] = dependency_provider, extra_dependencies: Sequence[model.Depends] = (), wrap_model: Callable[[CallModel[P, T]], CallModel[P, T]] = lambda x: x, ) -> Union[Union[Callable[P, T], Callable[P, Awaitable[T]]], _InjectWrapper[P, T],]: @@ -86,7 +79,7 @@ def inject( def _resolve_overrides_provider( - dependency_overrides_provider: Optional[HasDependencyOverrides], + dependency_overrides_provider: Optional[Any], ) -> Optional[dict[Callable[..., Any], Callable[..., Any]]]: if not dependency_overrides_provider: return None @@ -95,7 +88,7 @@ def _resolve_overrides_provider( def _wrap_inject( - dependency_overrides_provider: Optional[HasDependencyOverrides], + dependency_overrides_provider: Optional[Any], wrap_model: Callable[ [CallModel[P, T]], CallModel[P, T],