Skip to content

Commit 7257adc

Browse files
committed
fix: relax _parse_admin_form parameter type for FormData compat
Starlette's FormData is not Mapping[str, str] — values may be str or UploadFile. mypy on CI catches the mismatch (locally it slipped through under a more permissive version). Widen the parameter type to Mapping[str, Any]; the parser only reads keys that hold str values and coerces via str() where needed, so behaviour is unchanged.
1 parent a218884 commit 7257adc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

kardscm/web/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from collections.abc import Mapping
99
from contextlib import closing
1010
from pathlib import Path
11+
from typing import Any
1112

1213
from fastapi import Depends, FastAPI, Form, HTTPException, Query, Request, Response
1314
from fastapi.responses import HTMLResponse
@@ -411,14 +412,16 @@ def healthz() -> dict[str, str]:
411412
return app
412413

413414

414-
def _parse_admin_form(form: Mapping[str, str]) -> dict:
415+
def _parse_admin_form(form: Mapping[str, Any]) -> dict:
415416
"""Parse the admin edit form into a fields dict for update_card_admin.
416417
417418
Validates ranges and categorical values. Empty number inputs map to None.
418419
Title is required non-empty; text may be empty.
419420
420421
Args:
421422
form: A Starlette FormData (or any mapping-like object exposing .get).
423+
Values may be ``str`` or ``UploadFile``; non-string values for the
424+
keys this parser reads are coerced via ``str()`` where needed.
422425
"""
423426
fields: dict = {}
424427

0 commit comments

Comments
 (0)