From 466ce9dfb65b8c338dcba2df6ee552961b47585c Mon Sep 17 00:00:00 2001 From: Michael Riad Zaky Date: Wed, 29 Apr 2026 17:23:10 -0700 Subject: [PATCH] fix ruff: APIRouter type-checking import, replace print with sys.std* writes --- litellm/proxy/_lazy_features.py | 2 +- litellm/proxy/_lazy_openapi_snapshot.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/_lazy_features.py b/litellm/proxy/_lazy_features.py index d4cb7ddebf..d58bfbbdb5 100644 --- a/litellm/proxy/_lazy_features.py +++ b/litellm/proxy/_lazy_features.py @@ -17,7 +17,7 @@ from starlette.types import Receive, Scope, Send from litellm._logging import verbose_proxy_logger if TYPE_CHECKING: - from fastapi import FastAPI + from fastapi import APIRouter, FastAPI def _include_router(attr_name: str = "router") -> Callable[["FastAPI", object], None]: diff --git a/litellm/proxy/_lazy_openapi_snapshot.py b/litellm/proxy/_lazy_openapi_snapshot.py index 78028319e3..315f6a9742 100644 --- a/litellm/proxy/_lazy_openapi_snapshot.py +++ b/litellm/proxy/_lazy_openapi_snapshot.py @@ -40,7 +40,7 @@ def generate_snapshot() -> Dict[str, Dict]: module = importlib.import_module(feat.module_path) feat.register_fn(app, module) except Exception as exc: - print(f"warning: skip {feat.name}: {exc}", file=sys.stderr) + sys.stderr.write(f"warning: skip {feat.name}: {exc}\n") fragments: Dict[str, Dict] = {} for feat in LAZY_FEATURES: @@ -67,4 +67,4 @@ def generate_snapshot() -> Dict[str, Dict]: if __name__ == "__main__": fragments = generate_snapshot() SNAPSHOT_FILE.write_text(json.dumps(fragments, indent=2, sort_keys=True) + "\n") - print(f"wrote {len(fragments)} feature fragments to {SNAPSHOT_FILE}") + sys.stdout.write(f"wrote {len(fragments)} feature fragments to {SNAPSHOT_FILE}\n")