Jump to solution
Verify

The Fix

pip install pydantic==2.10.3

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

Jump to Verify Open PR/Commit
@@ -571,6 +571,15 @@ def deprecation_message(self) -> str | None: return self.deprecated if isinstance(self.deprecated, str) else self.deprecated.message + @property + def default_factory_takes_validated_data(self) -> bool | None: + """Whether the provided default factory callable has a validated data parameter.
repro.py
@override def get_raw(self, item: str) -> Any: if item in self._cache: return self._cache[item] field = self._config_model.model_fields[item] if not field.is_required(): self._cache[item] = field.get_default(call_default_factory=True) else: raise KeyError(f"config item {item!r} has no default value.")
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.3\nWhen NOT to use: This fix is not applicable if the default factory does not require validated_data.\n\n

Why This Fix Works in Production

  • Trigger: with the latest version of pydantic (`2.10.1`) and the mypy plugin, we observe some false positive with type validation.
  • Mechanism: The default factory in Pydantic now accepts a validated_data argument, causing mypy to raise false positives
  • Why the fix works: Add a property to check if the default factory callable has a validated data parameter, addressing the issue with mypy false positives. (first fixed release: 2.10.3).

Why This Breaks in Prod

  • Shows up under Python 3.11 in real deployments (not just unit tests).
  • The default factory in Pydantic now accepts a validated_data argument, causing mypy to raise false positives
  • Production symptom (often without a traceback): with the latest version of pydantic (`2.10.1`) and the mypy plugin, we observe some false positive with type validation.

Proof / Evidence

Discussion

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

“This is odd bc default_factory is typed as Callable[[], Any] | Callable[[dict[str, Any]], Any] | None”
@sydney-runkle · 2024-11-22 · source
“@Viicos i think your reply is not related to this issue.”
@l00ptr · 2024-11-28 · source
“Yes sorry I went to see the PR that mentioned the issue and thought it was the same person that raised it. In your case,…”
@Viicos · 2024-11-28 · source
“In 2.10, default factories may accept a new validated_data argument”
@Viicos · 2024-11-26 · source

Failure Signature (Search String)

  • with the latest version of pydantic (`2.10.1`) and the mypy plugin, we observe some false positive with type validation.
  • When running mypy over that piece of code, we observe that kind of error:
Copy-friendly signature
signature.txt
Failure Signature ----------------- with the latest version of pydantic (`2.10.1`) and the mypy plugin, we observe some false positive with type validation. When running mypy over that piece of code, we observe that kind of error:

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- with the latest version of pydantic (`2.10.1`) and the mypy plugin, we observe some false positive with type validation. When running mypy over that piece of code, we observe that kind of error:

Minimal Reproduction

repro.py
@override def get_raw(self, item: str) -> Any: if item in self._cache: return self._cache[item] field = self._config_model.model_fields[item] if not field.is_required(): self._cache[item] = field.get_default(call_default_factory=True) else: raise KeyError(f"config item {item!r} has no default value.")

Environment

  • Python: 3.11
  • Pydantic: 2

What Broke

Mypy reports false positive errors regarding default factory arguments during type validation.

Why It Broke

The default factory in Pydantic now accepts a validated_data argument, causing mypy to raise false positives

Fix Options (Details)

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

pip install pydantic==2.10.3

When NOT to use: This fix is not applicable if the default factory does not require validated_data.

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

First fixed release: 2.10.3

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 if the default factory does not require validated_data.

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

Related Issues

No related fixes found.

Sources

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