ty statically resolves Pydantic v1/v2 version checks; mypy and Pyright still false-positive

charliermarsh · x · 2026-12-03

Charlie Marsh (Astral) showed off ty's reachability analysis: code branching on the Pydantic version to call modeldumpjson (v2) vs json() (v1) type checks even with Pydantic v1 installed, because ty statically evaluates the version check and marks the v2-only branch unreachable.

He notes that under the same setup mypy, Pyright, Pyrefly and Zuban all emit a false positive on line 13, and that the capability is general — not Pydantic-specific.

Original post →

More from coding & agent

coding & agent channel →