TID251 bans typing.cast, so say why this one is allowed

ruff_strict_gate counts TID251 against the merge-base and the new cast import
put the file one over. The config's own note for that rule allows a suppression
with a reason, and the reasoning is narrow: response_format reaches us as an
arbitrary JSON object from the provider, and the branch immediately reads one
key off it and compares against three literal strings.

The stricter alternative in the rule's message is a pydantic boundary model.
That would be the right call if these values were persisted or forwarded to a
caller, and it is not here.

strict-rule counts now match the merge-base exactly. 164 tests pass and the
type-discipline and test-quality gates stay within their ceilings.
This commit is contained in:
JingHao-Leon 2026-10-11 21:28:46 +08:00
parent eafae88742
commit daf51cc878

View file

@ -11,7 +11,7 @@ import time
import uuid
from collections.abc import AsyncIterator, Iterator, Mapping, Sequence
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Final, cast
from typing import TYPE_CHECKING, Any, Final, cast # noqa: TID251 # response_format is a plain JSON object
import httpx