TRF060
Files in a model directory must import from transformers with relative imports, not from transformers....
| Default | Enabled |
| Scope | Models added on or after 2026-06-20 |
| Source | mlinter/trf060.py |
| Show in terminal | mlinter --rule TRF060 |
What it does
Flags from transformers... import X and import transformers... under src/transformers/models/ and suggests the relative form (from ...modeling_utils import X). convert_*.py scripts are skipped.
Why is this bad?
An absolute import inside the package goes through the lazy top-level transformers/__init__.py, which can cause circular imports, and can resolve to another installed copy of transformers.
Example
-from transformers.modeling_utils import PreTrainedModel
-from transformers.models.acme.configuration_acme import AcmeConfig
-from transformers import initialization as init
+from ...modeling_utils import PreTrainedModel
+from .configuration_acme import AcmeConfig
+from ... import initialization as init
Suppressing this rule
Add a # trf-ignore: TRF060 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
1 model are exempt from TRF060 in mlinter/rules.toml, because they predate the convention and cannot be changed without breaking backward compatibility.
Show the 1 allowlisted model
auto
