TRF030

Reaching more than two levels into the config means the module was handed the wrong config.

   
Default Enabled
Scope Models added on or after 2026-06-20
Source mlinter/trf030.py
Show in terminal mlinter --rule TRF030

What it does

In modeling_*.py and modular_*.py, flags attribute chains rooted at config or self.config that go three or more levels deep. config.hidden_size (one hop) and config.text_config.hidden_size (two hops, the normal sub-config access) are fine; one violation is reported per line.

Why is this bad?

A module that walks config.diffusion_config.atom_encoder_config.hidden_size is coupled to the whole config hierarchy rather than to its own slice of it, so it cannot be reused, tested or given a different sub-config. Pass the relevant sub-config down and the chain collapses to one hop.

Example

 class AcmeAtomEncoder(nn.Module):
     def __init__(self, config):
         super().__init__()
-        self.norm = AcmeLayerNorm(config.diffusion_config.atom_encoder_config.hidden_size)
+        self.norm = AcmeLayerNorm(config.hidden_size)

Suppressing this rule

Add a # trf-ignore: TRF030 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.