From 382900d7a8f5c6a8a58d781a6012feece82794d7 Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Mon, 27 Oct 2025 23:08:24 -0700 Subject: [PATCH] fix(mypy): resolve routes and type narrowing errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - routes.py: Use type ignore for intentional None endpoint - routes.py: Handle optional route.methods with fallback to empty list 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/llama_stack/core/server/routes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/llama_stack/core/server/routes.py b/src/llama_stack/core/server/routes.py index 4970d0bf8..48a961318 100644 --- a/src/llama_stack/core/server/routes.py +++ b/src/llama_stack/core/server/routes.py @@ -68,8 +68,9 @@ def get_all_api_routes( else: http_method = hdrs.METH_POST routes.append( - (Route(path=path, methods=[http_method], name=name, endpoint=None), webmethod) - ) # setting endpoint to None since don't use a Router object + # setting endpoint to None since don't use a Router object + (Route(path=path, methods=[http_method], name=name, endpoint=None), webmethod) # type: ignore[arg-type] + ) apis[api] = routes @@ -98,7 +99,7 @@ def initialize_route_impls(impls, external_apis: dict[Api, ExternalApiSpec] | No impl = impls[api] func = getattr(impl, route.name) # Get the first (and typically only) method from the set, filtering out HEAD - available_methods = [m for m in route.methods if m != "HEAD"] + available_methods = [m for m in (route.methods or []) if m != "HEAD"] if not available_methods: continue # Skip if only HEAD method is available method = available_methods[0].lower()