TRF057

Public model, config, output and processor classes and their public methods must carry @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 public PreTrainedModel subclasses (<Model>PreTrainedModel, <Model>Model, <Model>For<Task>, backbones), PreTrainedConfig subclasses, ModelOutput subclasses, image processors, video 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 modular_*.py is checked against the files generated from it.

Why is this bad?

Without it, the class and its methods ship without parameter, return and example documentation, which then has to be written by hand for each model.

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