From: Evgeny Bokshitsky Date: Sat, 20 Sep 2025 17:37:18 +0000 (+0400) Subject: ♻️ Create `dependency-cache` dict in `solve_dependencies` only if `None` (don't re... X-Git-Tag: 0.117.0~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2c6049b8f021a5a0576599ed36af930490173b2;p=thirdparty%2Ffastapi%2Ffastapi.git ♻️ Create `dependency-cache` dict in `solve_dependencies` only if `None` (don't re-create if empty) (#13689) --- diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index d9f6bf2d7..8dd0a14c8 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -593,7 +593,8 @@ async def solve_dependencies( response = Response() del response.headers["content-length"] response.status_code = None # type: ignore - dependency_cache = dependency_cache or {} + if dependency_cache is None: + dependency_cache = {} sub_dependant: Dependant for sub_dependant in dependant.dependencies: sub_dependant.call = cast(Callable[..., Any], sub_dependant.call) @@ -630,7 +631,6 @@ async def solve_dependencies( embed_body_fields=embed_body_fields, ) background_tasks = solved_result.background_tasks - dependency_cache.update(solved_result.dependency_cache) if solved_result.errors: errors.extend(solved_result.errors) continue