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
Checks classes decorated with both @auto_docstring and @dataclass for source ordering: @auto_docstring must appear above @dataclass.
Why is this bad?
Decorators are applied bottom-up. When @dataclass is listed above @auto_docstring, @auto_docstring runs first on a class that has no synthesized __init__ yet and ends up modifying the parent class’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.
