Skip to content

Commit 0d4bd35

Browse files
committed
fix(mypy): silence untyped FastAPI decorators in web.py (3.11 green)
1 parent 917dbcd commit 0d4bd35

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/diff_risk_dashboard/web.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
# FastAPI opcional: no se importa en tiempo de análisis para evitar fallos de mypy/CI.
2-
# Uso local:
3-
# python -m pip install "fastapi>=0.110" "uvicorn[standard]>=0.27"
4-
# python -m diff_risk_dashboard.web
51
from __future__ import annotations
62

73
from typing import Any
84

5+
# Importes perezosos para no requerir fastapi/uvicorn en CI
96
from .core import summarize_apv_json
107
from .report import to_markdown
118

@@ -15,10 +12,9 @@ def create_app() -> Any:
1512
responses = __import__("fastapi.responses", fromlist=["HTMLResponse"])
1613
FastAPI = getattr(fastapi, "FastAPI")
1714
HTMLResponse = getattr(responses, "HTMLResponse")
15+
app: Any = FastAPI(title="Diff Risk Dashboard")
1816

19-
app = FastAPI(title="Diff Risk Dashboard")
20-
21-
@app.get("/", response_class=HTMLResponse)
17+
@app.get("/", response_class=HTMLResponse) # type: ignore[misc]
2218
def index() -> Any:
2319
return HTMLResponse(
2420
content="""
@@ -33,11 +29,10 @@ def index() -> Any:
3329
status_code=200,
3430
)
3531

36-
@app.post("/summarize", response_class=HTMLResponse)
32+
@app.post("/summarize", response_class=HTMLResponse) # type: ignore[misc]
3733
async def summarize(file: Any) -> Any:
3834
data = await file.read()
39-
text = data.decode("utf-8")
40-
summary = summarize_apv_json(text)
35+
summary = summarize_apv_json(data.decode("utf-8"))
4136
md = to_markdown(summary).replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
4237
return HTMLResponse(f"<pre>{md}</pre>", status_code=200)
4338

0 commit comments

Comments
 (0)