mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-15 04:52:31 +08:00
13 lines
338 B
Python
13 lines
338 B
Python
from collections.abc import Mapping
|
|
|
|
|
|
def parse_optional_int_query_param(query: Mapping[str, str], name: str) -> int | None:
|
|
value = query.get(name)
|
|
if value is None:
|
|
return None
|
|
|
|
try:
|
|
return int(value)
|
|
except (TypeError, ValueError) as exc:
|
|
raise ValueError(f"{name} must be an integer") from exc
|