TRF035
Model files must not silence the linter with # noqa.
| Default | Enabled |
| Scope | Models added on or after 2026-06-20 |
| Source | mlinter/trf035.py |
| Show in terminal | mlinter --rule TRF035 |
What it does
Flags # noqa comments, with or without codes, in modeling_*.py, modular_*.py and configuration_*.py. In a modular file F401, F821 and F822 are accepted: it is a generation source that deliberately does not define every name it uses, so ruff’s undefined-name family fires on correct code – __all__ entries the converter fills in, classes living in the parent model, imports kept to be re-exported. A # noqa naming only those codes is skipped; one naming anything else is reported on the codes that are left. A bare # noqa is always reported; in a modular file the message asks for the code rather than a rewrite.
Why is this bad?
Model files are ordinary code held to the repo’s lint rules, so a suppression means the underlying issue was left in place – and a bare # noqa also hides every future violation on that line. Fix the code instead.
Example
-from ...modeling_utils import PreTrainedModel # noqa: F401
+from ...modeling_utils import PreTrainedModel
Suppressing this rule
Add a # trf-ignore: TRF035 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.
