TRF055
config on a PreTrainedModel subclass must be an annotation (config: SomeConfig), not an assignment (config = SomeConfig).
| Default | Enabled |
| Scope | All models |
| Source | mlinter/trf055.py |
| Show in terminal | mlinter --rule TRF055 |
What it does
Flags config = SomeConfig as a class attribute on PreTrainedModel subclasses in modeling_*.py and modular_*.py.
Why is this bad?
PreTrainedModel.__init_subclass__ derives config_class from a config **annotation**, via inspect.get_annotations(cls). An assignment creates a stray class attribute that call does not report, so the subclass silently keeps the parent’s config_class. A bare annotation has no runtime value, creates no attribute, and is picked up correctly.
Example
class Gemma4VisionModel(Gemma4PreTrainedModel):
"""The Gemma 4 Vision Encoder."""
- config = Gemma4VisionConfig
+ config: Gemma4VisionConfig
Suppressing this rule
Add a # trf-ignore: TRF055 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.
