Jump to solution
Verify

The Fix

Added support for `validation_alias` in the mypy plugin to resolve issues with missing named arguments.

Based on closed pydantic/pydantic issue #10991 · 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
@@ -1040,15 +1040,17 @@ def get_alias_info(stmt: AssignmentStmt) -> tuple[str | None, bool]: return None, False - for i, arg_name in enumerate(expr.arg_names): - if arg_name != 'alias': - continue
repro.py
import json from typing import ClassVar, Generic, Self, Set, TypeVar, Union from pydantic import BaseModel, ConfigDict, Field, field_validator _ResponseT = TypeVar('_ResponseT', bound=Union[BaseModel, dict]) class APIResponse(BaseModel, Generic[_ResponseT]): model_config = ConfigDict(populate_by_name=True) # This does not matter ok: bool = Field(validation_alias='is_success') status_code: int headers: dict body: _ResponseT = Field(validation_alias='content') # using `alias` works fine @field_validator('body', mode='before') @classmethod def convert_to_dict(cls, v: Union[str, bytes]) -> dict: return json.loads(v) APIResponse[dict]( ok=True, status_code=200, headers=headers or {}, content=b'{}', ) # Missing named argument "body" for "APIResponse" [call-arg]
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Apply the official fix\nAdded support for `validation_alias` in the mypy plugin to resolve issues with missing named arguments.\nWhen NOT to use: This fix should not be used if the mypy plugin is not being utilized.\n\n

Why This Fix Works in Production

  • Trigger: Pydantic-Mypy works with `alias`, but not with `validation_alias`
  • Mechanism: The mypy plugin did not support `validation_alias`, causing missing named argument errors
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).
  • The mypy plugin did not support `validation_alias`, causing missing named argument errors
  • Production symptom (often without a traceback): Pydantic-Mypy works with `alias`, but not with `validation_alias`

Proof / Evidence

Discussion

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

“### Initial Checks - [X] I confirm that I'm using Pydantic V2 ### Description So, when I use pydantic-mypy plugin, and define my fields and use model I get mypy error. The thing is, my field is using validation_alias (instead of alias). Run”
Issue thread · issue description · source

Failure Signature (Search String)

  • Pydantic-Mypy works with `alias`, but not with `validation_alias`
  • model_config = ConfigDict(populate_by_name=True) # This does not matter
Copy-friendly signature
signature.txt
Failure Signature ----------------- Pydantic-Mypy works with `alias`, but not with `validation_alias` model_config = ConfigDict(populate_by_name=True) # This does not matter

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Pydantic-Mypy works with `alias`, but not with `validation_alias` model_config = ConfigDict(populate_by_name=True) # This does not matter

Minimal Reproduction

repro.py
import json from typing import ClassVar, Generic, Self, Set, TypeVar, Union from pydantic import BaseModel, ConfigDict, Field, field_validator _ResponseT = TypeVar('_ResponseT', bound=Union[BaseModel, dict]) class APIResponse(BaseModel, Generic[_ResponseT]): model_config = ConfigDict(populate_by_name=True) # This does not matter ok: bool = Field(validation_alias='is_success') status_code: int headers: dict body: _ResponseT = Field(validation_alias='content') # using `alias` works fine @field_validator('body', mode='before') @classmethod def convert_to_dict(cls, v: Union[str, bytes]) -> dict: return json.loads(v) APIResponse[dict]( ok=True, status_code=200, headers=headers or {}, content=b'{}', ) # Missing named argument "body" for "APIResponse" [call-arg]

Environment

  • Python: 3.12
  • Pydantic: 2

What Broke

Users experienced mypy errors related to missing named arguments when using `validation_alias`.

Why It Broke

The mypy plugin did not support `validation_alias`, causing missing named argument errors

Fix Options (Details)

Option A — Apply the official fix

Added support for `validation_alias` in the mypy plugin to resolve issues with missing named arguments.

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

Fix reference: https://github.com/pydantic/pydantic/pull/11295

Last verified: 2026-02-11. 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 used if the mypy plugin is not being utilized.

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.

Related Issues

No related fixes found.

Sources

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