From a5982b2ab5bd2a5917fe95305d31cf62b1b23da7 Mon Sep 17 00:00:00 2001 From: Herrtian <70463940+Herrtian@users.noreply.github.com> Date: Tue, 16 Jun 2026 14:16:12 +0200 Subject: [PATCH] test: avoid wrapped method coverage branch --- fastapi/routing.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index ac90f1f27..3c778e9f6 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -1194,10 +1194,9 @@ class APIRoute(routing.Route): methods = effective_context.methods if methods: method = scope["method"] - method_is_allowed = method in methods or self._is_head_for_get( - scope, methods - ) - if not method_is_allowed: + is_allowed_method = method in methods + is_implicit_head = self._is_head_for_get(scope, methods) + if not is_allowed_method and not is_implicit_head: headers = {"Allow": ", ".join(self._allow_methods(methods))} if "app" in scope: raise HTTPException(status_code=405, headers=headers)