TRF031
Dataclasses in modeling files must inherit ModelOutput.
| Default | Enabled |
| Scope | Models added on or after 2026-06-20 |
| Source | mlinter/trf031.py |
| Show in terminal | mlinter --rule TRF031 |
What it does
In modeling_*.py and modular_*.py, flags a top-level @dataclass class whose bases do not include something ending in Output.
Why is this bad?
A plain dataclass does not index like a tuple, does not survive return_dict=False, and is invisible to @auto_docstring, so its fields never reach the generated API docs. Inheriting ModelOutput gets all three for free.
Example
@auto_docstring
@dataclass
-class AcmeStructureOutput:
+class AcmeStructureOutput(ModelOutput):
positions: torch.Tensor
confidence: torch.Tensor
Suppressing this rule
Add a # trf-ignore: TRF031 comment on the flagged line or the line directly above it. See Suppressing rules for whole-file directives and when a suppression is the wrong answer.
