RepoJournal
FastAPI & Pydantic

FastAPI & Pydantic

FastAPI and the Pydantic + SQLModel async-Python stack

Keep up with FastAPI & Pydantic in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.

One email a day. Unsubscribe in one click.

Pick a date

Topics: Python Full archive →

The Wire · Showcase

PYDANTIC FIXES DEEPCOPY CRASH IN MODEL_COPY

By RepoJournal · Filed · About FastAPI & Pydantic

Pydantic's `model_copy(deep=True)` no longer tries to deepcopy fields you're about to replace, fixing crashes when those fields hold undeepcopyable objects like GPU tensors or C extensions.

The fix [1] is surgical and high-impact. Before, `model_copy(deep=True, update={...})` would deepcopy every field including ones you're immediately replacing, which breaks when those fields contain native C extensions, file handles, or GPU tensors. Now it only deepcopies fields that survive the update, and it properly maintains shared references between fields by using a single `memo` dict across all deepcopy calls. This preserves the behavior for `__pydantic_extra__` and `__pydantic_private__` as well. In parallel, the Pydantic team fixed a mypy plugin regression [2] where `create_model(..., __base__=cls)` inside a classmethod would lose the `Self` type. The mypy plugin now falls back to the normal overload definition when `__base__` is a type variable, keeping proper generic inference. Expect these in the next release.

One email a day. Unsubscribe in one click.

Action items

References

  1. [1] Only deepcopy non-updated fields in `model_copy()` ↗ pydantic/pydantic
  2. [2] Fallback to `create_model()` overload definition when `__base__` is set to a type variable ↗ pydantic/pydantic

Quick answers

What shipped in FastAPI & Pydantic on May 17, 2026?
Pydantic's `model_copy(deep=True)` no longer tries to deepcopy fields you're about to replace, fixing crashes when those fields hold undeepcopyable objects like GPU tensors or C extensions. In total, 6 commits and 6 pull requests landed.
Who contributed to FastAPI & Pydantic on May 17, 2026?
2 developers shipped this update, including connorcarpenter15 and cyphercodes.
What were the notable FastAPI & Pydantic updates?
Only deepcopy non-updated fields in `model_copy()` and Fallback to `create_model()` overload definition when `__base__` is set to a type variable.

More from FastAPI & Pydantic

Daily updates, in your inbox

Follow FastAPI & Pydantic

Keep up with FastAPI & Pydantic in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.

or

One email a day. Unsubscribe in one click. Read a past issue →

Elsewhere on the wire

Want every project, not just this one?