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%.
@@ -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__
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())
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.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).
- 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
- GitHub issue: #10039
- Fix PR: https://github.com/pydantic/pydantic/pull/10100
- First fixed release: 2.9.2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.60
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…”
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
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 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
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
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.
When NOT to Use This Fix
- Do not apply this fix if the generic behavior is intentionally designed to be different.
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.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.