Jump to solution
Verify

The Fix

pip install pydantic==1.10.16

Based on closed pydantic/pydantic issue #9532 · 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
@@ -687,7 +687,7 @@ may need to explicitly specify the generic parameter: from pydantic import TypeAdapter -adapter: TypeAdapter[str | int] = TypeAdapter(str | int) +adapter = TypeAdapter[str | int](str | int) ...
repro.py
from pydantic import TypeAdapter ad1 = TypeAdapter(str | int) # ad1: TypeAdapter[UnionType] ad2 = TypeAdapter[str | int](str | int) # ad1: TypeAdapter[str | int] result1 = ad1.validate_python("foo") # result1: UnionType result2 = ad2.validate_python(42) # result2: str | 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==1.10.16\nWhen NOT to use: Do not use this fix if you require strict type hints without manual annotations.\n\n

Why This Fix Works in Production

  • Trigger: For most simple error reproduction on command-line and to prove occurence of `Any` type, copy above snippet in `main.py` and invoke `basedpyright` on it (or…
  • Mechanism: Fixes the typing of `TypeAdapter` to ensure proper type hints for Union types starting from Pydantic 2.7.0.
  • Why the fix works: Fixes the typing of `TypeAdapter` to ensure proper type hints for Union types starting from Pydantic 2.7.0. (first fixed release: 1.10.16).

Why This Breaks in Prod

  • Triggered by an upgrade/regression window: 2.7.0 breaks; 1.10.16 is the first fixed release.
  • Production symptom (often without a traceback): For most simple error reproduction on command-line and to prove occurence of `Any` type, copy above snippet in `main.py` and invoke `basedpyright` on it (or use IDE of choice with `pyright` and hover over types):

Proof / Evidence

  • GitHub issue: #9532
  • Fix PR: https://github.com/pydantic/pydantic/pull/9570
  • First fixed release: 1.10.16
  • Affected versions: 2.7.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.59

Discussion

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

“Duplicate of https://github.com/pydantic/pydantic/issues/9147, https://github.com/pydantic/pydantic/discussions/7094 https://discuss.python.org/t/typeform-spelling-for-a-type-annotation-object-at-runtime/51435 is what's needed for TypeAdapter to work with spec”
@Viicos · 2024-05-31 · source
“Hi @Viicos, thanks for mentioning those issues”
@mark-henry01 · 2024-06-01 · source
“> Hi @Viicos, thanks for mentioning those issues”
@Viicos · 2024-06-03 · source

Failure Signature (Search String)

  • For most simple error reproduction on command-line and to prove occurence of `Any` type, copy above snippet in `main.py` and invoke `basedpyright` on it (or use IDE of choice with
  • /path/to/proj/main.py:8:1 - error: Type of "result1" is Any (reportAny)
Copy-friendly signature
signature.txt
Failure Signature ----------------- For most simple error reproduction on command-line and to prove occurence of `Any` type, copy above snippet in `main.py` and invoke `basedpyright` on it (or use IDE of choice with `pyright` and hover over types): /path/to/proj/main.py:8:1 - error: Type of "result1" is Any (reportAny)

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- For most simple error reproduction on command-line and to prove occurence of `Any` type, copy above snippet in `main.py` and invoke `basedpyright` on it (or use IDE of choice with `pyright` and hover over types): /path/to/proj/main.py:8:1 - error: Type of "result1" is Any (reportAny)

Minimal Reproduction

repro.py
from pydantic import TypeAdapter ad1 = TypeAdapter(str | int) # ad1: TypeAdapter[UnionType] ad2 = TypeAdapter[str | int](str | int) # ad1: TypeAdapter[str | int] result1 = ad1.validate_python("foo") # result1: UnionType result2 = ad2.validate_python(42) # result2: str | int

Environment

  • Pydantic: 2.7.0

What Broke

Type hints for `TypeAdapter` become less specific, leading to IDE errors.

Fix Options (Details)

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

pip install pydantic==1.10.16

When NOT to use: Do not use this fix if you require strict type hints without manual annotations.

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

First fixed release: 1.10.16

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 use this fix if you require strict type hints without manual annotations.

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.7.0 Broken
1.10.16 Fixed

Related Issues

No related fixes found.

Sources

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