Jump to solution
Verify

The Fix

pip install pydantic==2.9.2

Based on closed pydantic/pydantic issue #10039 · 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
@@ -133,6 +133,8 @@ def wrapped_model_post_init(self: BaseModel, context: Any, /) -> None: namespace['__class_vars__'] = class_vars namespace['__private_attributes__'] = {**base_private_attributes, **private_attributes} + if __pydantic_generic_metadata__: + namespace['__pydantic_generic_metadata__'] = __pydantic_generic_metadata__
repro.py
from typing import Generic, TypeVar from pydantic import BaseModel T = TypeVar('T') class MyClass(BaseModel, Generic[T]): pass class MyClassSub(MyClass[T]): pass class MyClassSubBool(MyClassSub[bool]): pass class Model(BaseModel): input_bool: MyClass[bool] if __name__ == '__main__': instance_fails = Model(input_bool=MyClassSubBool())
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.9.2\nWhen NOT to use: Do not apply this fix if the generic behavior is intentionally designed to be different.\n\n

Why This Fix Works in Production

  • Trigger: If I use multiple inheritance in `class MyClassSubBool(MyClassSub, MyClass[bool])` I do get the example to work, but it doesn't seem the most pythonic way.
  • Mechanism: The method resolution order (MRO) for generic subclasses was not correctly handling indexed generic types
  • Why the fix works: Fixes the method resolution order (MRO) for generic subclasses in Pydantic, allowing indexed generic types to be correctly inserted into the MRO of their subclasses. (first fixed release: 2.9.2).
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 method resolution order (MRO) for generic subclasses was not correctly handling indexed generic types
  • Production symptom (often without a traceback): If I use multiple inheritance in `class MyClassSubBool(MyClassSub, MyClass[bool])` I do get the example to work, but it doesn't seem the most pythonic way.

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“I simplified your example code to make it easier to understand. Overall I think this is a reasonable request, it is accepted from a type…”
@Viicos · 2024-08-04 · source

Failure Signature (Search String)

  • If I use multiple inheritance in `class MyClassSubBool(MyClassSub, MyClass[bool])` I do get the example to work, but it doesn't seem the most pythonic way.
Copy-friendly signature
signature.txt
Failure Signature ----------------- If I use multiple inheritance in `class MyClassSubBool(MyClassSub, MyClass[bool])` I do get the example to work, but it doesn't seem the most pythonic way.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- If I use multiple inheritance in `class MyClassSubBool(MyClassSub, MyClass[bool])` I do get the example to work, but it doesn't seem the most pythonic way.

Minimal Reproduction

repro.py
from typing import Generic, TypeVar from pydantic import BaseModel T = TypeVar('T') class MyClass(BaseModel, Generic[T]): pass class MyClassSub(MyClass[T]): pass class MyClassSubBool(MyClassSub[bool]): pass class Model(BaseModel): input_bool: MyClass[bool] if __name__ == '__main__': instance_fails = Model(input_bool=MyClassSubBool())

Environment

  • Pydantic: 2

What Broke

Instances of generic subclasses failed to validate as expected, causing runtime errors.

Why It Broke

The method resolution order (MRO) for generic subclasses was not correctly handling indexed generic types

Fix Options (Details)

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

pip install pydantic==2.9.2

When NOT to use: Do not apply this fix if the generic behavior is intentionally designed to be different.

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

First fixed release: 2.9.2

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

  • Do not apply this fix if the generic behavior is intentionally designed to be different.

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

Related Issues

No related fixes found.

Sources

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