Skip to content

PY-MODE0005 · standard_dataclass_model

Replace state-bearing standard dataclasses with the approved model foundation.

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

Report a Python class decorated with the standard dataclass decorator when it declares at least one field and no ordinary behavior. Such a class is already a data model, so the project foundation should own validation, serialization, immutability, and schema policy consistently.

Each finding names the dataclass and its field count. The value is the number of declarative dataclasses in the file.

A class whose identity is a language interop record or whose methods implement ordinary behavior can remain a dataclass through a path exclusion. Empty marker classes are handled by the separate nonempty-model rule.

@dataclass class Point with x and y fields is reported. class Point(FrozenModel) is the accepted project model shape.