Jump to solution
Verify

The Fix

pip install pydantic==2.10.0

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

Jump to Verify Open PR/Commit
@@ -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__
repro.py
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
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.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

Discussion

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

“@rmorshea, Thanks for the feature request”
@sydney-runkle · 2024-05-16 · source
“I have a similar case - a fix would be most helpful!”
@tonygoldman · 2024-08-27 · source
“voting up for this feature 👍 I have quite complext structure with many generics, so pydantic supporting default would be most helpful :)”
@stasbel · 2024-09-27 · source

Failure Signature (Search String)

  • f("hello") # error because str not subtype of int
  • f("hello") # no error
Copy-friendly signature
signature.txt
Failure Signature ----------------- f("hello") # error because str not subtype of int f("hello") # no error

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- f("hello") # error because str not subtype of int f("hello") # no error

Minimal Reproduction

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

When NOT to use: This fix is not applicable for TypeVars that do not require both a bound and a default.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

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