Skip to content

PY-MODE0006 · empty_declarative_model

Require every declarative model to own at least one field.

This is a deterministic rule for python. Read its implementation.

Report a recognized Pydantic, house model, SQL table, or dataclass with no declared or inherited fields. A model without state is a namespace, marker, or behavior holder and should state that narrower role directly instead of paying for a data-model foundation.

Each finding names the empty model and its exact source range. The value is the number of empty declarative models in the file.

A foundation is not a model. A base that owns no fields and either states the model_config every class below it inherits or is already derived by classes that do own fields exists to fix validation policy, so it is read as the foundation rather than as an empty model, wherever the project keeps it. Framework-required sentinel models can remain through an exact path exclusion. Protocols and abstract behavioral contracts are not concrete data models and are excluded.

class Ready(FrozenModel): pass is reported. class Ready(FrozenModel): value: bool and an explicit Protocol are accepted. A base whose whole body is model_config is also accepted, since it states what everything below it derives.

  • Cites “Pydantic documentation”, models. Open reference
  • Cites “Refactoring”, Data Class