]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
⚡️ Stop retaining flat dependency trees (#16065)
authorSebastián Ramírez <tiangolo@gmail.com>
Mon, 27 Jul 2026 14:06:31 +0000 (16:06 +0200)
committerGitHub <noreply@github.com>
Mon, 27 Jul 2026 14:06:31 +0000 (16:06 +0200)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
fastapi/routing.py

index f3ff6c172e6e9524321ab4f28da8aa718663ffcb..125ab51ae7be2aca2629e04011ae2291c85e620c 100644 (file)
@@ -807,7 +807,7 @@ class APIWebSocketRoute(routing.WebSocketRoute):
         self.path_regex, self.path_format, self.param_convertors = compile_path(path)
         (
             self.dependant,
-            self._flat_dependant,
+            _,
             self._embed_body_fields,
         ) = _build_dependant_with_parameterless_dependencies(
             path=self.path_format,
@@ -944,7 +944,6 @@ class _APIRouteLike(Protocol):
     description: str
     response_fields: dict[int | str, ModelField]
     dependant: Dependant
-    _flat_dependant: Dependant
     _embed_body_fields: bool
     body_field: ModelField | None
     is_sse_stream: bool
@@ -1091,7 +1090,7 @@ def _populate_api_route_state(
     assert callable(endpoint), "An endpoint must be a callable"
     (
         route.dependant,
-        route._flat_dependant,
+        flat_dependant,
         route._embed_body_fields,
     ) = _build_dependant_with_parameterless_dependencies(
         path=route.path_format,
@@ -1099,7 +1098,7 @@ def _populate_api_route_state(
         dependencies=route.dependencies,
     )
     route.body_field = get_body_field(
-        flat_dependant=route._flat_dependant,
+        flat_dependant=flat_dependant,
         name=route.unique_id,
         embed_body_fields=route._embed_body_fields,
     )
@@ -1145,7 +1144,6 @@ class APIRoute(routing.Route):
     description: str
     response_fields: dict[int | str, ModelField]
     dependant: Dependant
-    _flat_dependant: Dependant
     _embed_body_fields: bool
     body_field: ModelField | None
     is_sse_stream: bool
@@ -1410,7 +1408,6 @@ class _EffectiveRouteContext:
     description: str = ""
     response_fields: dict[int | str, ModelField] = field(default_factory=dict)
     dependant: Dependant | None = None
-    _flat_dependant: Dependant | None = None
     _embed_body_fields: bool = False
     body_field: ModelField | None = None
     is_sse_stream: bool = False
@@ -1486,7 +1483,7 @@ class _EffectiveRouteContext:
         )
         (
             context.dependant,
-            context._flat_dependant,
+            _,
             context._embed_body_fields,
         ) = _build_dependant_with_parameterless_dependencies(
             path="",
@@ -2080,7 +2077,7 @@ class _FrontendRouteGroup(BaseRoute):
         self.dependency_overrides_provider = dependency_overrides_provider
         (
             self.dependant,
-            self._flat_dependant,
+            _,
             self._embed_body_fields,
         ) = _build_dependant_with_parameterless_dependencies(
             path="",