Jump to solution
Verify

The Fix

pip install pydantic==2.12.4

Based on closed pydantic/pydantic issue #12421 · PR/commit linked

Jump to Verify Open PR/Commit
@@ -526,6 +526,13 @@ def _eval_type( localns, type_params=type_params, + # This is relevant when evaluating types from `TypedDict` classes, where string annotations + # are automatically converted to `ForwardRef` instances with a module set. In this case, + # Our `globalns` is irrelevant and we need to indicate `typing._eval_type()` that it should
repro.py
from __future__ import annotations from typing import TypedDict, Required class A(TypedDict): x: Required[int]
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.4\nWhen NOT to use: This fix should not be used if the application relies on the previous behavior of deferred imports.\n\n

Why This Fix Works in Production

  • Trigger: python b.py
  • Mechanism: Fixes an issue with forward references in parent TypedDict classes that caused failures in Pydantic 2.12 when used with Python 3.14.
  • Why the fix works: Fixes an issue with forward references in parent TypedDict classes that caused failures in Pydantic 2.12 when used with Python 3.14. (first fixed release: 2.12.4).
Production impact:
  • If left unfixed, this can cause silent data inconsistencies that propagate (bad cache entries, incorrect downstream decisions).

Why This Breaks in Prod

  • Shows up under Python 3.14 in real deployments (not just unit tests).
  • Surfaces as: python b.py

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 Pydantic 2.12 fails to resolve deferred imports in Python 3.14 See the example below. Notes: * reproduced with Python 3.14.0 * not reproduced with Python 3.13.2 *”
Issue thread · issue description · source

Failure Signature (Search String)

  • python b.py

Error Message

Stack trace
error.txt
Error Message ------------- python b.py Traceback (most recent call last): File "/private/tmp/b.py", line 10, in <module> C.model_validate({"c": {"x": 1}}) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/Users/christophe.bornet/.pyenv/versions/3.14.0/lib/python3.14/site-packages/pydantic/main.py", line 716, in model_validate return cls.__pydantic_validator__.validate_python( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/christophe.bornet/.pyenv/versions/3.14.0/lib/python3.14/site-packages/pydantic/_internal/_mock_val_ser.py", line 100, in __getattr__ raise PydanticUserError(self._error_message, code=self._code) pydantic.errors.PydanticUserError: `C` is not fully defined; you should define `Required`, then call `C.model_rebuild()`. For further information visit https://errors.pydantic.dev/2.12/u/class-not-fully-defined

Minimal Reproduction

repro.py
from __future__ import annotations from typing import TypedDict, Required class A(TypedDict): x: Required[int]

Environment

  • Python: 3.14
  • Pydantic: 2

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install pydantic==2.12.4

When NOT to use: This fix should not be used if the application relies on the previous behavior of deferred imports.

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/12427

First fixed release: 2.12.4

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 application relies on the previous behavior of deferred imports.

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.4 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.