TRF057

Public model, config, output and processor classes and their public methods must be decorated with @auto_docstring.

   
Default Enabled
Scope Models added on or after 2026-06-20
Source mlinter/trf057.py
Show in terminal mlinter --rule TRF057

What it does

Checks @auto_docstring on the classes that need it: public PreTrainedModel subclasses (<Model>PreTrainedModel, <Model>Model, <Model>For<Task>, backbones), PreTrainedConfig subclasses, ModelOutput subclasses, image processors and ProcessorMixin subclasses, and on their public methods: forward, get_image_features, get_video_features, get_audio_features, get_text_features, preprocess and __call__. A class or method in a modular_*.py file is checked against the files generated from it.

Why is this bad?

Without the decorator, a class ships with no intro and no parameter documentation, and a method with no argument documentation, no Returns section and no usage example, so the standard descriptions in auto_docstring.py have to be hand-written per model instead.

Example

+@auto_docstring
 @dataclass
 class AcmeModelOutputWithPast(ModelOutput):
     logits: torch.FloatTensor | None = None

+@auto_docstring
 class AcmeForConditionalGeneration(AcmePreTrainedModel):
+    @auto_docstring
     def forward(self, input_ids, pixel_values=None, **kwargs):
         ...

Suppressing this rule

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

Allowlisted models

6 models are exempt from TRF057 in mlinter/rules.toml, because they predate the convention and cannot be changed without breaking backward compatibility.

Show the 6 allowlisted models
  • kosmos2
  • timm_backbone
  • timm_wrapper
  • vitpose_backbone
  • wav2vec2_with_lm
  • x_clip