Jump to solution
Verify

The Fix

pip install pydantic==2.10.0

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

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -6,7 +6,7 @@ from copy import copy from functools import lru_cache -from inspect import Parameter, signature +from inspect import Parameter, ismethoddescriptor, signature from typing import TYPE_CHECKING, Any, Callable, Pattern
repro.py
from collections.abc import Callable from pydantic import BaseModel, Field class SomeModel(BaseModel): @staticmethod def default_int_factory() -> int: ... # This is fine # int_factory: Callable[[], int] = default_int_factory # This blows up: TypeError: cannot pickle 'staticmethod' object int_factory: Callable[[], int] = Field(default=default_int_factory)
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 should not be applied if the staticmethod is not intended for use as a default value.\n\n

Why This Fix Works in Production

  • Trigger: Bug: `TypeError: cannot pickle 'staticmethod' object` with a `Field.default`
  • Mechanism: Ensures that class access of method descriptors is performed when used as a default with `Field`, addressing the TypeError encountered with static methods.
  • Why the fix works: Ensures that class access of method descriptors is performed when used as a default with `Field`, addressing the TypeError encountered with static methods. (first fixed release: 2.10.0).
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

  • Triggered by an upgrade/regression window: 3.10 breaks; 2.10.0 is the first fixed release.
  • Shows up under Python 3.12 in real deployments (not just unit tests).
  • Surfaces as: Bug: `TypeError: cannot pickle 'staticmethod' object` with a `Field.default`

Proof / Evidence

  • GitHub issue: #10551
  • Fix PR: https://github.com/pydantic/pydantic/pull/10816
  • First fixed release: 2.10.0
  • Affected versions: 3.10
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.95
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.63

Verified Execution

We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.

  • Status: PASS
  • Ran: 2026-02-11T16:52:29Z
  • Package: pydantic
  • Fixed: 2.10.0
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)

Discussion

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

“To me, I think bullet 1 sounds better because it seems: 1”
@jamesbraza · 2024-10-04 · source
“Related discussion for stdlib dataclasses: https://github.com/python/cpython/issues/102646”
@Viicos · 2024-11-11 · source
“Interesting things are happening here”
@Viicos · 2024-10-04 · source

Failure Signature (Search String)

  • Bug: `TypeError: cannot pickle 'staticmethod' object` with a `Field.default`

Error Message

Stack trace
error.txt
Error Message ------------- Bug: `TypeError: cannot pickle 'staticmethod' object` with a `Field.default`

Minimal Reproduction

repro.py
from collections.abc import Callable from pydantic import BaseModel, Field class SomeModel(BaseModel): @staticmethod def default_int_factory() -> int: ... # This is fine # int_factory: Callable[[], int] = default_int_factory # This blows up: TypeError: cannot pickle 'staticmethod' object int_factory: Callable[[], int] = Field(default=default_int_factory)

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

Users encounter a TypeError when attempting to use staticmethods as default values in Pydantic models.

Fix Options (Details)

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

pip install pydantic==2.10.0

When NOT to use: This fix should not be applied if the staticmethod is not intended for use as a default value.

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

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 should not be applied if the staticmethod is not intended for use as a default value.

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