Jump to solution
Verify

The Fix

pip install pydantic==2.10.6

Based on closed pydantic/pydantic issue #10707 · 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
@@ -95,6 +95,7 @@ 'pydantic.deprecated.class_validators.root_validator', } +IMPLICIT_CLASSMETHOD_DECORATOR_FULLNAMES = DECORATOR_FULLNAMES - {'pydantic.functional_serializers.model_serializer'}
repro.py
from typing import Literal from pydantic import BaseModel, model_serializer class TemperatureModel(BaseModel): unit: Literal["C", "F"] value: int def _calculate_is_hot(self, value: int) -> bool: if self.unit == "F": return value > 100 return value > 38 @model_serializer(when_used="json") def serialize_model(self) -> dict[str, int | str | bool]: var: int = self.value if self.unit == "F": return { "unit": "C", "value": int((self.value - 32) / 1.8), "is_hot": self._calculate_is_hot(var), } return { "unit": self.unit, "value": self.value, "is_hot": self._calculate_is_hot(var), } temperature = TemperatureModel(unit="F", value=212) print(temperature.model_dump_json())
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.6\nWhen NOT to use: This fix should not be applied if the mypy plugin is not used.\n\n

Why This Fix Works in Production

  • Trigger: mypy incorrectly identifies argument of method within a model_serializer as incorrect
  • Mechanism: Mypy plugin incorrectly transforms model serializer functions as class methods
  • Why the fix works: Addresses an issue where mypy incorrectly identifies arguments of methods within a model_serializer as incorrect. (first fixed release: 2.10.6).
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

  • Shows up under Python 3.12 in real deployments (not just unit tests).
  • Mypy plugin incorrectly transforms model serializer functions as class methods
  • Production symptom (often without a traceback): mypy incorrectly identifies argument of method within a model_serializer as incorrect

Proof / Evidence

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.6
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)
{"unit":"C","value":100,"is_hot":true}

Discussion

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

“I have noticed the following: And then you do: With the plugin enabled you get: FYI @Viicos”
@MiguelElGallo · 2024-10-29 · source

Failure Signature (Search String)

  • mypy incorrectly identifies argument of method within a model_serializer as incorrect
  • demo.py:21: error: Missing positional argument "value" in call to "_calculate_is_hot" of "TemperatureModel" [call-arg]
Copy-friendly signature
signature.txt
Failure Signature ----------------- mypy incorrectly identifies argument of method within a model_serializer as incorrect demo.py:21: error: Missing positional argument "value" in call to "_calculate_is_hot" of "TemperatureModel" [call-arg]

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- mypy incorrectly identifies argument of method within a model_serializer as incorrect demo.py:21: error: Missing positional argument "value" in call to "_calculate_is_hot" of "TemperatureModel" [call-arg]

Minimal Reproduction

repro.py
from typing import Literal from pydantic import BaseModel, model_serializer class TemperatureModel(BaseModel): unit: Literal["C", "F"] value: int def _calculate_is_hot(self, value: int) -> bool: if self.unit == "F": return value > 100 return value > 38 @model_serializer(when_used="json") def serialize_model(self) -> dict[str, int | str | bool]: var: int = self.value if self.unit == "F": return { "unit": "C", "value": int((self.value - 32) / 1.8), "is_hot": self._calculate_is_hot(var), } return { "unit": self.unit, "value": self.value, "is_hot": self._calculate_is_hot(var), } temperature = TemperatureModel(unit="F", value=212) print(temperature.model_dump_json())

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

Mypy reports incorrect type errors when using model_serializer decorator.

Why It Broke

Mypy plugin incorrectly transforms model serializer functions as class methods

Fix Options (Details)

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

pip install pydantic==2.10.6

When NOT to use: This fix should not be applied if the mypy plugin is not used.

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

First fixed release: 2.10.6

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 mypy plugin is not used.

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

Related Issues

No related fixes found.

Sources

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