Jump to solution
Verify

The Fix

pip install pydantic==2.10.4

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

Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.

Jump to Verify Open PR/Commit
@@ -1197,7 +1197,9 @@ except PydanticUserError as exc_info: ## Unsupported type for `validate_call` {#validate-call-type} -`validate_call` has some limitations on the callables it can validate. This error is raised when you try to use it with an unsupported callable. Currently the supported callables are functions (including lambdas) and methods and instances of [`partial`][functools.partial]. In the case of [`partial`][functools.partial], the function being partially applied must be one of the supported callables. +`validate_call` has some limitations on the callables it can validate. This error is raised when you try to use it with an unsupported callable. +Currently the supported callables are functions (including lambdas, but not built-ins) and methods and instances of [`partial`][functools.partial].
repro.py
from __future__ import annotations import dataclasses import typing import uuid from datetime import timedelta import pydantic.dataclasses @pydantic.dataclasses.dataclass(kw_only=True) class SqsSendMessageBatchRequestEntry: id: str = dataclasses.field(default_factory=lambda: str(uuid.uuid4())) delay: timedelta = None msg_attrs: dict = dataclasses.field(default_factory=lambda: {}) msg_sys_attrs: dict = dataclasses.field(default_factory=lambda: {}) msg_dedupe_id: str = None msg_group_id: str = None @pydantic.validate_call def sqs_send_message_batch[T: (SqsSendMessageBatchRequestEntry, str, dict)]( queue_name_or_url: str, entries: T|typing.Iterable[T], ): pass
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.4\nWhen NOT to use: This fix should not be applied if the codebase does not utilize PEP 695 type parameters.\n\n

Why This Fix Works in Production

  • Trigger: pydantic.errors.PydanticUndefinedAnnotation: name 'T' is not defined when using from __future__ import annotations with a genetic function
  • Mechanism: The error occurs due to improper handling of PEP 695 type parameters in generic functions
  • Why the fix works: Addresses the issue of PydanticUndefinedAnnotation when using from __future__ import annotations with a generic function. (first fixed release: 2.10.4).
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 error occurs due to improper handling of PEP 695 type parameters in generic functions
  • Production symptom (often without a traceback): pydantic.errors.PydanticUndefinedAnnotation: name 'T' is not defined when using from __future__ import annotations with a genetic function

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 Running the below code fails with **pydantic.errors.PydanticUndefinedAnnotation: name 'T' is not defined** It works just fine in 2.9.2, if that helps. ### Example”
Issue thread · issue description · source

Failure Signature (Search String)

  • pydantic.errors.PydanticUndefinedAnnotation: name 'T' is not defined when using from __future__ import annotations with a genetic function
  • Running the below code fails with **pydantic.errors.PydanticUndefinedAnnotation: name 'T' is not defined**
Copy-friendly signature
signature.txt
Failure Signature ----------------- pydantic.errors.PydanticUndefinedAnnotation: name 'T' is not defined when using from __future__ import annotations with a genetic function Running the below code fails with **pydantic.errors.PydanticUndefinedAnnotation: name 'T' is not defined**

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- pydantic.errors.PydanticUndefinedAnnotation: name 'T' is not defined when using from __future__ import annotations with a genetic function Running the below code fails with **pydantic.errors.PydanticUndefinedAnnotation: name 'T' is not defined**

Minimal Reproduction

repro.py
from __future__ import annotations import dataclasses import typing import uuid from datetime import timedelta import pydantic.dataclasses @pydantic.dataclasses.dataclass(kw_only=True) class SqsSendMessageBatchRequestEntry: id: str = dataclasses.field(default_factory=lambda: str(uuid.uuid4())) delay: timedelta = None msg_attrs: dict = dataclasses.field(default_factory=lambda: {}) msg_sys_attrs: dict = dataclasses.field(default_factory=lambda: {}) msg_dedupe_id: str = None msg_group_id: str = None @pydantic.validate_call def sqs_send_message_batch[T: (SqsSendMessageBatchRequestEntry, str, dict)]( queue_name_or_url: str, entries: T|typing.Iterable[T], ): pass

Environment

  • Pydantic: 2

What Broke

Users experience crashes when using generic functions with annotations, leading to application downtime.

Why It Broke

The error occurs due to improper handling of PEP 695 type parameters in generic functions

Fix Options (Details)

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

pip install pydantic==2.10.4

When NOT to use: This fix should not be applied if the codebase does not utilize PEP 695 type parameters.

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

First fixed release: 2.10.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 applied if the codebase does not utilize PEP 695 type parameters.

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

Related Issues

No related fixes found.

Sources

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