Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix ruff: APIRouter type-checking import, replace print with sys.std* writes

Michael Riad Zaky466ce9dfb65b
diff --git a/litellm/proxy/_lazy_features.py b/litellm/proxy/_lazy_features.py
index d4cb7ddebfd..d58bfbbdb52 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 78028319e3e..315f6a9742a 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")