PyCharm 2026.2 Help

Pydantic

Pydantic is a data validation library that defines data models through standard Python type annotations. PyCharm provides dedicated support for Pydantic models, built on top of the same type engine that powers other type-hinting features.

The support covers pydantic.BaseModel and its subclasses, pydantic.dataclasses.dataclass, generic models, and related constructs such as Field, model and field validators, and ConfigDict options. Both Pydantic v1 and v2 are recognized.

Code insight for model fields

When you instantiate a Pydantic model, PyCharm treats the declared fields as keyword arguments of __init__ and provides the following code insight:

  • Completion of field names as keyword arguments, considering their declared types and default values.

  • Type checking of values passed for each field against the corresponding annotation.

  • An inspection that highlights missing required fields.

  • Navigation from a keyword argument in an __init__ call to the field declaration and back, including across subclasses and base classes.

from pydantic import BaseModel class User(BaseModel): id: int name: str is_active: bool = True User(id=1, name="Alice") # valid User(id="not-an-int", name="Steve") # type mismatch on id User(id=1) # name is missing

Field aliases and validation config

Fields declared with an alias through Field(alias=...) are accepted as keyword arguments in constructor calls without a false "unexpected argument" warning.

PyCharm respects the model's ConfigDict, so code insight in the editor matches the runtime validation behavior:

  • populate_by_name=True or validate_by_name=True — the field name is accepted in addition to its alias.

  • validate_by_alias=True — the alias is accepted for validation.

When both options are enabled, the field name and its alias are treated as valid keyword arguments:

from pydantic import BaseModel, Field class Model(BaseModel, validate_by_name=True, validate_by_alias=True): my_field: str = Field(alias='my_alias') Model(my_alias='foo') # valid Model(my_field='foo') # valid

Refactorings and validators

Renaming a model field updates all keyword arguments in __init__ calls and propagates the change to subclasses and base classes. Renaming a keyword argument in an __init__ call updates the corresponding field declaration the same way.

Field and model validators declared with @field_validator, @model_validator, or the legacy @validator and @root_validator decorators are recognized as such: the first parameter is typed accordingly, and standard inspections for the decorated functions are adjusted to avoid false positives.

20 July 2026