Inspectopedia 2026.3 Help

Pydantic dataclass

Reports incorrect or unsafe configuration of pydantic dataclasses and models that are discovered via the PEP 681 dataclass_transform mechanism.

The inspection currently checks for:

  • Invalid validation configuration: both validate_by_alias and validate_by_name are set to False (for example via model_config or __pydantic_config__), which disables all field matching during validation.

  • Mutating frozen Pydantic fields: assignments to or deletions of attributes declared with Field(frozen=True) in Pydantic models and dataclasses.

Invalid validation configuration

from pydantic import BaseModel, ConfigDict class User(BaseModel): model_config = ConfigDict( validate_by_alias=False, validate_by_name=False, # <-- both flags set to False: reported ) name: str username: str

Mutating a frozen field

from pydantic import BaseModel, Field class User(BaseModel): id: int = Field(frozen=True) name: str user = User(id=1, name="Jane") user.id = 2 # <-- write to frozen field: reported del user.id # <-- deletion of frozen field: reported

You can disable this inspection or change its severity in the Settings | Editor | Inspections dialog.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

PydanticDataclass
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Python | General

Inspection ID: PydanticDataclassInspection

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection PydanticDataclass

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2026.3, PyCharm 2026.3, Qodana for JVM 2026.3,

Last modified: 20 November 2026