style(rmi-backend): complete lint cleanup — 1175→0 ruff errors
- Fix 71 invalid-syntax files (class-body newline-broken assignments) - Add from/None chain to 307 B904 raise-without-from sites - Add B008 ignore to ruff.toml (already in pyproject.toml) - Noqa F401 on __init__.py re-exports (137 sites) - Noqa E402 on deferred imports (63 sites) - Bulk-add stdlib/FastAPI/project imports for F821 (127 sites) - Replace ×→x, –→-, …→... in docstrings (4093 chars) - Manual refactor of 5 SIM103/SIM116 patterns Tests: 791 passed (66 deselected due to pre-existing Redis issues in test_rag.py) Co-authored-by: opencode <opencode@rugmunch.io>
This commit is contained in:
parent
ca9bdce365
commit
c762564d40
688 changed files with 5165 additions and 5142 deletions
|
|
@ -1,11 +1,11 @@
|
|||
"""RMI Backend — middleware registration.
|
||||
"""RMI Backend - middleware registration.
|
||||
|
||||
Per v3 unfuck rule #7: add_middleware MUST be called at module level,
|
||||
NOT inside lifespan. FastAPI rejects middleware added after startup.
|
||||
|
||||
This module owns every middleware registration. Adding a new middleware:
|
||||
1. Add a `try_register(app, "name")` block below
|
||||
2. Each block is isolated — one failure doesn't break the rest
|
||||
2. Each block is isolated - one failure doesn't break the rest
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ def register_middleware(app) -> None:
|
|||
|
||||
|
||||
def _try_register_cors(app) -> None:
|
||||
"""T19 — CORS hardening with strict allowlist."""
|
||||
"""T19 - CORS hardening with strict allowlist."""
|
||||
try:
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
ALLOWED_ORIGINS = [
|
||||
|
|
@ -50,7 +50,7 @@ def _try_register_cors(app) -> None:
|
|||
|
||||
|
||||
def _try_register_security_headers(app) -> None:
|
||||
"""T20 — Security headers on every response."""
|
||||
"""T20 - Security headers on every response."""
|
||||
try:
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from starlette.requests import Request
|
||||
|
|
@ -89,7 +89,7 @@ def _try_register_prometheus(app) -> None:
|
|||
|
||||
|
||||
def _try_register_cost_tracking(app) -> None:
|
||||
"""M7 — per-tenant/per-route cost tracking."""
|
||||
"""M7 - per-tenant/per-route cost tracking."""
|
||||
try:
|
||||
from app.middleware.cost_tracking import CostBuffer, CostTrackingMiddleware
|
||||
app.add_middleware(CostTrackingMiddleware, buffer=CostBuffer())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue