From 7df26d1ac76aabf52f74ce75e5f908ccf28b4898 Mon Sep 17 00:00:00 2001 From: Okot Daniel Date: Mon, 11 Aug 2025 11:46:16 +0300 Subject: [PATCH 1/4] docs(declarative.rst): fix grammar in Declarative Container documentation (#916) fixes #915 --- docs/containers/declarative.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/containers/declarative.rst b/docs/containers/declarative.rst index febc0bf9..e464f49e 100644 --- a/docs/containers/declarative.rst +++ b/docs/containers/declarative.rst @@ -16,7 +16,7 @@ The declarative container providers should only be used when you have the contai Working with the providers of the container on the class level will influence all further instances. -The declarative container can not have any methods or any other attributes then providers. +A declarative container cannot have any methods or attributes other than providers. The container class provides next attributes: From e2cf0d0d30ff2cef644eeae7048b63763d4191ba Mon Sep 17 00:00:00 2001 From: AndrianEquestrian Date: Thu, 23 Oct 2025 14:35:36 +0300 Subject: [PATCH 2/4] Fast depends v3 compatibility fix --- src/dependency_injector/wiring.py | 20 +++++++++++++++++++- tox.ini | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/dependency_injector/wiring.py b/src/dependency_injector/wiring.py index 211fdcde..4d8c2e4f 100644 --- a/src/dependency_injector/wiring.py +++ b/src/dependency_injector/wiring.py @@ -76,11 +76,29 @@ def extract_marker_from_fastapi(param: Any) -> Any: MARKER_EXTRACTORS.append(extract_marker_from_fastapi) +# Fast-depends support for both old and new versions +FastDepends = None +FastDependant = None + +# Try to import from different locations to support both versions +with suppress(ImportError): + # Try version 3.0.0+ first (Dependant from model) + from fast_depends.dependencies.model import Dependant as FastDependant + + def extract_marker_from_dependant_fast_depends(param: Any) -> Any: + # Check for Dependant (3.0.0+) + if FastDependant is not None and isinstance(param, FastDependant): + return param.dependency + return None + + MARKER_EXTRACTORS.append(extract_marker_from_dependant_fast_depends) + with suppress(ImportError): + # Try version < 3.0.0 (Depends class) from fast_depends.dependencies import Depends as FastDepends def extract_marker_from_fast_depends(param: Any) -> Any: - if isinstance(param, FastDepends): + if FastDepends is not None and isinstance(param, FastDepends): return param.dependency return None diff --git a/tox.ini b/tox.ini index cadccd84..ccb0b971 100644 --- a/tox.ini +++ b/tox.ini @@ -17,7 +17,7 @@ deps= mypy_boto3_s3 pydantic-settings werkzeug - fast-depends + fast-depends==3.0.0 extras= yaml commands = pytest @@ -45,7 +45,7 @@ deps = boto3 mypy_boto3_s3 werkzeug - fast-depends + fast-depends==3.0.0 commands = pytest -m pydantic [testenv:coveralls] From 133b1409c61a40130c06a2ec272b9374d731fc4f Mon Sep 17 00:00:00 2001 From: AndrianEquestrian Date: Thu, 23 Oct 2025 14:39:26 +0300 Subject: [PATCH 3/4] fixup! Fast depends v3 compatibility fix --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index ccb0b971..cadccd84 100644 --- a/tox.ini +++ b/tox.ini @@ -17,7 +17,7 @@ deps= mypy_boto3_s3 pydantic-settings werkzeug - fast-depends==3.0.0 + fast-depends extras= yaml commands = pytest @@ -45,7 +45,7 @@ deps = boto3 mypy_boto3_s3 werkzeug - fast-depends==3.0.0 + fast-depends commands = pytest -m pydantic [testenv:coveralls] From 4a5c86a71f986191071a819a1593a82ba628aab9 Mon Sep 17 00:00:00 2001 From: ZipFile Date: Thu, 23 Oct 2025 12:30:46 +0000 Subject: [PATCH 4/4] fixup! Fast depends v3 compatibility fix --- src/dependency_injector/wiring.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/dependency_injector/wiring.py b/src/dependency_injector/wiring.py index 4d8c2e4f..ceeee74e 100644 --- a/src/dependency_injector/wiring.py +++ b/src/dependency_injector/wiring.py @@ -76,29 +76,21 @@ def extract_marker_from_fastapi(param: Any) -> Any: MARKER_EXTRACTORS.append(extract_marker_from_fastapi) -# Fast-depends support for both old and new versions -FastDepends = None -FastDependant = None - -# Try to import from different locations to support both versions -with suppress(ImportError): - # Try version 3.0.0+ first (Dependant from model) - from fast_depends.dependencies.model import Dependant as FastDependant +with suppress(ImportError): # fast_depends >=3.0.0 + from fast_depends.dependencies.model import Dependant as FastDependant # type: ignore[attr-defined] def extract_marker_from_dependant_fast_depends(param: Any) -> Any: - # Check for Dependant (3.0.0+) - if FastDependant is not None and isinstance(param, FastDependant): + if isinstance(param, FastDependant): return param.dependency return None MARKER_EXTRACTORS.append(extract_marker_from_dependant_fast_depends) -with suppress(ImportError): - # Try version < 3.0.0 (Depends class) - from fast_depends.dependencies import Depends as FastDepends +with suppress(ImportError): # fast_depends <3.0.0 + from fast_depends.dependencies import Depends as FastDepends # type: ignore[attr-defined] def extract_marker_from_fast_depends(param: Any) -> Any: - if FastDepends is not None and isinstance(param, FastDepends): + if isinstance(param, FastDepends): return param.dependency return None