The Fix
pip install pydantic==2.12.0
Based on closed pydantic/pydantic issue #12278 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -955,15 +955,9 @@ def set_frozen(self, fields: list[PydanticModelField], api: SemanticAnalyzerPlug
# See https://github.com/pydantic/pydantic/issues/5191 to hit this branch for test coverage
self._api.defer()
- else: # pragma: no cover
- # I don't know whether it's possible to hit this branch, but I've added it for safety
- try:
from pydantic import BaseModel, Field, computed_field
class Parent(BaseModel):
parent_attr: str = Field(exclude=True)
class Chield(Parent):
child_attr: str = Field(exclude=True)
@computed_field
@property
def parent_attr(self) -> str:
return self.child_attr
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.12.0\nWhen NOT to use: This fix should not be used if the mypy plugin behavior is expected to remain unchanged.\n\n
Why This Fix Works in Production
- Trigger: The pydantic mypy plugin ran into unexpected behavior [pydantic-unexpected]
- Mechanism: The Pydantic mypy plugin fails when fields are overridden by methods, causing unexpected behavior
- Why the fix works: Addresses unexpected behavior in the Pydantic mypy plugin when fields are overridden by methods. (first fixed release: 2.12.0).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- The Pydantic mypy plugin fails when fields are overridden by methods, causing unexpected behavior
- Production symptom (often without a traceback): The pydantic mypy plugin ran into unexpected behavior [pydantic-unexpected]
Proof / Evidence
- GitHub issue: #12278
- Fix PR: https://github.com/pydantic/pydantic/pull/12290
- First fixed release: 2.12.0
- 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.58
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“### Initial Checks - [x] I confirm that I'm using Pydantic V2 ### Description I know I shouldn't have parent_attr as a property for a child class (mypy will complain about it), but I got a bug from the pydantic plugin: uv run mypy main.py -”
Failure Signature (Search String)
- The pydantic mypy plugin ran into unexpected behavior [pydantic-unexpected]
- main.py:8: error: The pydantic mypy plugin ran into unexpected behavior: sym_node.node: Decorator:11(
Copy-friendly signature
Failure Signature
-----------------
The pydantic mypy plugin ran into unexpected behavior [pydantic-unexpected]
main.py:8: error: The pydantic mypy plugin ran into unexpected behavior: sym_node.node: Decorator:11(
Error Message
Signature-only (no traceback captured)
Error Message
-------------
The pydantic mypy plugin ran into unexpected behavior [pydantic-unexpected]
main.py:8: error: The pydantic mypy plugin ran into unexpected behavior: sym_node.node: Decorator:11(
Minimal Reproduction
from pydantic import BaseModel, Field, computed_field
class Parent(BaseModel):
parent_attr: str = Field(exclude=True)
class Chield(Parent):
child_attr: str = Field(exclude=True)
@computed_field
@property
def parent_attr(self) -> str:
return self.child_attr
Environment
- Pydantic: 2
What Broke
Users encounter mypy errors when using the Pydantic mypy plugin with overridden fields.
Why It Broke
The Pydantic mypy plugin fails when fields are overridden by methods, causing unexpected behavior
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.12.0
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/12290
First fixed release: 2.12.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the mypy plugin behavior is expected to remain unchanged.
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.12.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.