Skip to content

Commit dad7b0f

Browse files
Add fast stream depends integration
1 parent 2fe4c39 commit dad7b0f

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/dependency_injector/wiring.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,23 @@ def get_origin(tp):
102102
else:
103103
Container = Any
104104

105+
def _is_fastapi_depends(param: Any) -> bool:
106+
return fastapi and isinstance(param, fastapi.params.Depends)
107+
108+
109+
if fast_depends:
110+
def _is_fast_stream_depends(param: Any) -> bool:
111+
return isinstance(param, fast_depends.dependencies.Depends)
112+
else:
113+
def _is_fast_stream_depends(param: Any) -> bool:
114+
return False
115+
116+
117+
_DEPENDS_CHECKERS = (
118+
_is_fastapi_depends,
119+
_is_fast_stream_depends,
120+
)
121+
105122

106123
class PatchedRegistry:
107124

@@ -600,7 +617,7 @@ def _extract_marker(parameter: inspect.Parameter) -> Optional["_Marker"]:
600617
else:
601618
marker = parameter.default
602619

603-
if _is_fastapi_depends(marker) or _is_fast_stream_depends(marker):
620+
if any(depends_checker(marker) for depends_checker in _DEPENDS_CHECKERS):
604621
depends_available = True
605622

606623
if not isinstance(marker, _Marker) and not depends_available:
@@ -728,18 +745,6 @@ def _get_patched(
728745
return patched
729746

730747

731-
def _is_fastapi_depends(param: Any) -> bool:
732-
return fastapi and isinstance(param, fastapi.params.Depends)
733-
734-
735-
if fast_depends:
736-
def _is_fast_stream_depends(param: Any) -> bool:
737-
return isinstance(param, fast_depends.dependencies.Depends)
738-
else:
739-
def _is_fast_stream_depends(param: Any) -> bool:
740-
return False
741-
742-
743748
def _is_patched(fn) -> bool:
744749
return _patched_registry.has_callable(fn)
745750

0 commit comments

Comments
 (0)