TRF061
A class in a modular_*.py file must not subclass another class defined in the same file.
| Default | Enabled |
| Scope | Models added on or after 2026-06-20 |
| Source | mlinter/trf061.py |
| Show in terminal | mlinter --rule TRF061 |
What it does
In modular_*.py, flags a class whose base is defined earlier in the same file. Bases imported from another model, <Model>PreTrainedModel subclasses and backward-compatibility aliases are not flagged.
Why is this bad?
The converter inlines bases imported from other models but keeps a same-file base, so the generated modeling file keeps the inheritance and its classes can no longer be read one at a time.
Example
from ..llama.modeling_llama import LlamaDecoderLayer
class AcmeDecoderLayer(LlamaDecoderLayer):
pass
-class AcmeSparseDecoderLayer(AcmeDecoderLayer):
+class AcmeSparseDecoderLayer(LlamaDecoderLayer):
def __init__(self, config, layer_idx):
super().__init__(config, layer_idx)
self.mlp = AcmeSparseMoeBlock(config)
Suppressing this rule
Add a # trf-ignore: TRF061 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
2 models are exempt from TRF061 in mlinter/rules.toml, because they predate the convention and cannot be changed without breaking backward compatibility.
Show the 2 allowlisted models
esmfold2granite_speech5
