Pydantic hacks Mypy detection: why type checkers crawl and how to fake your way to speed
charliermarsh · x · 2026-11-21
Charlie Marsh (author of Ruff/uv) shares a fun engineering find: Pydantic's source contains a Mypy-specific workaround — a massive CoreSchema TypeAlias is only constructed when a MYPY constant is true, because union types otherwise grind type checkers to a halt, hurting not just Pydantic but any code using it. His punchline: if you want your type checker to be faster on Pydantic, just tell it you are Mypy. Screenshot shows the relevant code in pydantic-core's coreschema.py.
More from coding & agent
- DeepMind's Antigravity Robotics Plugin: 2 Prompts, ~20 Minutes to Command a Real FR3 Duo Arm — jackyliang42 · 2026-11-21
- Ruff author warns: setting MYPY speeds up type checking on Pydantic but collapses types to Mapping[str, Any] — charliermarsh · 2026-11-21
- Asking Astra 6.2 to Review Code Written by Opus 5.5 Yields Almost Nothing — rickasaurus · 2026-11-21
- Security & Web3 Firewall MCP Server Hits Official Registry: Detects Tool-Poisoning and Rug-Pull Drift — ezelech · 2026-11-21
- Artificial Analysis Launches Search API Benchmark Covering 26 Products Across 14 Providers — ArtificialAnlys · 2026-11-21
- MAI Code 2 hands-on: replacing Claude as orchestrator, tops Terminal-Bench — imdigitalashish · 2026-11-21