mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-11-24 11:55:47 +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)
|
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):
|
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
|
from fast_depends.dependencies import Depends as FastDepends
|
||||||
|
|
||||||
def extract_marker_from_fast_depends(param: Any) -> Any:
|
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 param.dependency
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
||||||
4
tox.ini
4
tox.ini
|
|
@ -17,7 +17,7 @@ deps=
|
||||||
mypy_boto3_s3
|
mypy_boto3_s3
|
||||||
pydantic-settings
|
pydantic-settings
|
||||||
werkzeug
|
werkzeug
|
||||||
fast-depends
|
fast-depends==3.0.0
|
||||||
extras=
|
extras=
|
||||||
yaml
|
yaml
|
||||||
commands = pytest
|
commands = pytest
|
||||||
|
|
@ -45,7 +45,7 @@ deps =
|
||||||
boto3
|
boto3
|
||||||
mypy_boto3_s3
|
mypy_boto3_s3
|
||||||
werkzeug
|
werkzeug
|
||||||
fast-depends
|
fast-depends==3.0.0
|
||||||
commands = pytest -m pydantic
|
commands = pytest -m pydantic
|
||||||
|
|
||||||
[testenv:coveralls]
|
[testenv:coveralls]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user