TRF017

@auto_docstring must be placed above @dataclass on output classes.

   
Default Enabled
Scope All models
Source mlinter/trf017.py
Show in terminal mlinter --rule TRF017

What it does

On classes carrying both @auto_docstring and @dataclass, checks @auto_docstring comes first.

Why is this bad?

Decorators apply bottom-up, so @dataclass on top runs @auto_docstring first, on a class with no synthesized __init__ yet: it then modifies the parent’s __init__.__doc__ instead of the subclass’s.

Example

-@dataclass
 @auto_docstring(
     custom_intro="""
     Output type of [`AcmeForPreTraining`].
     """
 )
+@dataclass
 class AcmeForPreTrainingOutput(ModelOutput):
     ...

Suppressing this rule

Add a # trf-ignore: TRF017 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.