Skip to content

Commit 4a5c86a

Browse files
committed
fixup! Fast depends v3 compatibility fix
1 parent 133b140 commit 4a5c86a

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/dependency_injector/wiring.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,21 @@ def extract_marker_from_fastapi(param: Any) -> Any:
7676

7777
MARKER_EXTRACTORS.append(extract_marker_from_fastapi)
7878

79-
# Fast-depends support for both old and new versions
80-
FastDepends = None
81-
FastDependant = None
82-
83-
# Try to import from different locations to support both versions
84-
with suppress(ImportError):
85-
# Try version 3.0.0+ first (Dependant from model)
86-
from fast_depends.dependencies.model import Dependant as FastDependant
79+
with suppress(ImportError): # fast_depends >=3.0.0
80+
from fast_depends.dependencies.model import Dependant as FastDependant # type: ignore[attr-defined]
8781

8882
def extract_marker_from_dependant_fast_depends(param: Any) -> Any:
89-
# Check for Dependant (3.0.0+)
90-
if FastDependant is not None and isinstance(param, FastDependant):
83+
if isinstance(param, FastDependant):
9184
return param.dependency
9285
return None
9386

9487
MARKER_EXTRACTORS.append(extract_marker_from_dependant_fast_depends)
9588

96-
with suppress(ImportError):
97-
# Try version < 3.0.0 (Depends class)
98-
from fast_depends.dependencies import Depends as FastDepends
89+
with suppress(ImportError): # fast_depends <3.0.0
90+
from fast_depends.dependencies import Depends as FastDepends # type: ignore[attr-defined]
9991

10092
def extract_marker_from_fast_depends(param: Any) -> Any:
101-
if FastDepends is not None and isinstance(param, FastDepends):
93+
if isinstance(param, FastDepends):
10294
return param.dependency
10395
return None
10496

0 commit comments

Comments
 (0)