mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-11-24 03:45:48 +03:00
Fast depends v3 compatibility fix
This commit is contained in:
parent
5a1aef9203
commit
e2cf0d0d30
|
|
@ -76,11 +76,29 @@ with suppress(ImportError):
|
|||
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user