From 8e81e99c25139ed8f4ee33a352e55c13d0c02b60 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 18 May 2026 21:46:24 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Auto=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/routing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index 3abe0f2eb0..b72c4ea1ed 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -258,7 +258,11 @@ class EndpointContext(TypedDict, total=False): # Use a WeakKeyDictionary instead of a standard dict to prevent memory leaks # and cache collisions when endpoints are dynamically created and destroyed. # This cache will only be used for the fallback "slow path". -_endpoint_context_cache: weakref.WeakKeyDictionary[Any, EndpointContext] = weakref.WeakKeyDictionary() +_endpoint_context_cache: weakref.WeakKeyDictionary[Any, EndpointContext] = ( + weakref.WeakKeyDictionary() +) + + def _extract_endpoint_context(func: Any) -> EndpointContext: """Extract endpoint context with caching to avoid repeated file I/O."""