Fast depends v3 compatibility fix

This commit is contained in:
AndrianEquestrian 2025-10-23 14:35:36 +03:00
parent 5a1aef9203
commit e2cf0d0d30
2 changed files with 21 additions and 3 deletions

View File

@ -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

View File

@ -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]