The Fix
pip install pydantic==2.10.0
Based on closed pydantic/pydantic issue #9418 · PR/commit linked
@@ -1892,34 +1892,27 @@ def _call_schema(self, function: ValidateCallSupportedTypes) -> core_schema.Call
def _unsubstituted_typevar_schema(self, typevar: typing.TypeVar) -> core_schema.CoreSchema:
- assert isinstance(typevar, typing.TypeVar)
-
- bound = typevar.__bound__
from typing_extensions import TypeVar
T = TypeVar("T", bound=int, default=int)
def f(x: T = 1) -> T:
return x
f("hello") # error because str not subtype of int
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.10.0\nWhen NOT to use: This fix is not applicable for TypeVars that do not require both a bound and a default.\n\n
Why This Fix Works in Production
- Trigger: f("hello") # error because str not subtype of int
- Mechanism: Pydantic does not support TypeVar with both a bound and a default declared
- Why the fix works: Adds support for TypeVar with both a default and a bound or constraints, addressing issue #9418. (first fixed release: 2.10.0).
Why This Breaks in Prod
- Pydantic does not support TypeVar with both a bound and a default declared
- Production symptom (often without a traceback): f("hello") # error because str not subtype of int
Proof / Evidence
- GitHub issue: #9418
- Fix PR: https://github.com/pydantic/pydantic/pull/10789
- First fixed release: 2.10.0
- 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.66
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“@rmorshea, Thanks for the feature request”
“I have a similar case - a fix would be most helpful!”
“voting up for this feature 👍 I have quite complext structure with many generics, so pydantic supporting default would be most helpful :)”
Failure Signature (Search String)
- f("hello") # error because str not subtype of int
- f("hello") # no error
Copy-friendly signature
Failure Signature
-----------------
f("hello") # error because str not subtype of int
f("hello") # no error
Error Message
Signature-only (no traceback captured)
Error Message
-------------
f("hello") # error because str not subtype of int
f("hello") # no error
Minimal Reproduction
from typing_extensions import TypeVar
T = TypeVar("T", bound=int, default=int)
def f(x: T = 1) -> T:
return x
f("hello") # error because str not subtype of int
What Broke
Users experience type warnings not being raised when using TypeVar with only a default.
Why It Broke
Pydantic does not support TypeVar with both a bound and a default declared
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install pydantic==2.10.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/10789
First fixed release: 2.10.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable for TypeVars that do not require both a bound and a default.
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.10.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.