Jump to solution
Verify

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%.

Jump to Verify Open PR/Commit
@@ -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:
repro.py
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
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
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).
Production impact:
  • 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

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 -”
Issue thread · issue description · source

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
signature.txt
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.txt
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

repro.py
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

When NOT to use: This fix should not be used if the mypy plugin behavior is expected to remain unchanged.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be used if the mypy plugin behavior is expected to remain unchanged.

Verify Fix

verify
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

VersionStatus
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.