From 45acd328f2cd328a8c1693bd736e0718ccaefa4d Mon Sep 17 00:00:00 2001 From: Volodymyr Kochetkov Date: Sat, 30 Dec 2023 13:17:57 +0200 Subject: [PATCH] feat: issue-2008 fix linter --- fastapi/routing.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index 41f83fff0..d1ecab7d0 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -931,11 +931,12 @@ class APIRouter(routing.Router): auto_options_index: Optional[int] = None allowed_methods: Set[str] = set() for index, route in enumerate(self.routes): - if route.path == new_route.path: - if hasattr(route, "is_auto_options") and route.is_auto_options: - auto_options_index = index - else: - allowed_methods.update(route.methods) + if isinstance(route, APIRoute): + if route.path == new_route.path: + if hasattr(route, "is_auto_options") and route.is_auto_options: + auto_options_index = index + else: + allowed_methods.update(route.methods) if auto_options_index is not None: self.routes.pop(auto_options_index)