The Fix
pip install pydantic==2.11.4
Based on closed pydantic/pydantic issue #11727 · PR/commit linked
@@ -5,7 +5,7 @@
from collections.abc import Iterator
from configparser import ConfigParser
-from typing import Any, Callable, cast
+from typing import Any, Callable
from pydantic import (
BaseModel,
RootModel,
)
ListInputType = list['DataTypeModel']
class DataTypeModel(RootModel):
root: ListInputType
class ColumnModel(BaseModel):
type: DataTypeModel
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install pydantic==2.11.4\nWhen NOT to use: This fix should not be applied if the code relies on the previous behavior of the mypy plugin.\n\n
Why This Fix Works in Production
- Trigger: transformer.transform()
- Mechanism: The mypy plugin crashes when expanding root types due to unsolved forward references
- Why the fix works: Fixes a crash when expanding root type in the mypy plugin, addressing an issue introduced in Pydantic 2.11.0. (first fixed release: 2.11.4).
Why This Breaks in Prod
- Shows up under Python 3.13 in real deployments (not just unit tests).
- The mypy plugin crashes when expanding root types due to unsolved forward references
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #11727
- Fix PR: https://github.com/pydantic/pydantic/pull/11735
- First fixed release: 2.11.4
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.39
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thanks for the report, this will be fixed in the next patch release.”
“Confirming that the issue is fixed from our perspective 🎉”
Failure Signature (Search String)
- transformer.transform()
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "mypy/semanal.py", line 7240, in accept
File "mypy/nodes.py", line 1177, in accept
File "mypy/semanal.py", line 1728, in visit_class_def
File "mypy/semanal.py", line 1944, in analyze_class
File "mypy/semanal.py", line 1991, in analyze_class_body_common
File "mypy/semanal.py", line 2076, in apply_class_plugin_hooks
File "/virtualenv/.venv/lib/python3.13/site-packages/pydantic/mypy.py", line 162, in _pydantic_model_class_maker_callback
transformer.transform()
~~~~~~~~~~~~~~~~~~~~~^^
File "/virtualenv/.venv/lib/python3.13/site-packages/pydantic/mypy.py", line 473, in transform
self.add_model_construct_method(fields, config, is_settings, is_a_root_model)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/virtualenv/.venv/lib/python3.13/site-packages/pydantic/mypy.py", line 916, in add_model_construct_method
args = self.get_field_arguments(
fields,
...<5 lines>...
is_root_model=is_root_model,
)
File "/virtualenv/.venv/lib/python3.13/site-packages/pydantic/mypy.py", line 1116, in get_field_arguments
field.to_argument(
~~~~~~~~~~~~~~~~~^
info,
^^^^^
...<6 lines>...
is_root_model_root=is_root_model and field.name == 'root',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/virt
... (truncated) ...
Minimal Reproduction
from pydantic import (
BaseModel,
RootModel,
)
ListInputType = list['DataTypeModel']
class DataTypeModel(RootModel):
root: ListInputType
class ColumnModel(BaseModel):
type: DataTypeModel
Environment
- Python: 3.13
- Pydantic: 2
What Broke
Users experience crashes when running mypy with the pydantic plugin on specific models.
Why It Broke
The mypy plugin crashes when expanding root types due to unsolved forward references
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.11.4
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/pydantic/pydantic/pull/11735
First fixed release: 2.11.4
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the code relies on the previous behavior of the mypy plugin.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
Version Compatibility Table
| Version | Status |
|---|---|
| 2.11.4 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.