MCPcopy
hub / github.com/fastapi/fastapi / _solve_dependencies

Method _solve_dependencies

fastapi/routing.py:2171–2207  ·  view source on GitHub ↗
(
        self,
        scope: Scope,
        receive: Receive,
        send: Send,
        *,
        dependant: Dependant,
        dependency_overrides_provider: Any | None,
        embed_body_fields: bool,
    )

Source from the content-addressed store, hash-verified

2169 # duplicated here
2170 @asynccontextmanager
2171 async def _solve_dependencies(
2172 self,
2173 scope: Scope,
2174 receive: Receive,
2175 send: Send,
2176 *,
2177 dependant: Dependant,
2178 dependency_overrides_provider: Any | None,
2179 embed_body_fields: bool,
2180 ) -> AsyncIterator[None]:
2181 request = Request(scope, receive, send)
2182 previous_inner_astack = scope.get("fastapi_inner_astack", _SCOPE_MISSING)
2183 previous_function_astack = scope.get("fastapi_function_astack", _SCOPE_MISSING)
2184 try:
2185 async with AsyncExitStack() as request_stack:
2186 scope["fastapi_inner_astack"] = request_stack
2187 async with AsyncExitStack() as function_stack:
2188 scope["fastapi_function_astack"] = function_stack
2189 solved_result = await solve_dependencies(
2190 request=request,
2191 dependant=dependant,
2192 dependency_overrides_provider=dependency_overrides_provider,
2193 async_exit_stack=request_stack,
2194 embed_body_fields=embed_body_fields,
2195 )
2196 if solved_result.errors:
2197 raise RequestValidationError(solved_result.errors)
2198 yield
2199 finally:
2200 if previous_inner_astack is _SCOPE_MISSING:
2201 scope.pop("fastapi_inner_astack", None)
2202 else:
2203 scope["fastapi_inner_astack"] = previous_inner_astack
2204 if previous_function_astack is _SCOPE_MISSING:
2205 scope.pop("fastapi_function_astack", None)
2206 else:
2207 scope["fastapi_function_astack"] = previous_function_astack
2208
2209
2210class APIRouter(routing.Router):

Callers 1

handleMethod · 0.95

Calls 3

solve_dependenciesFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected