TRF038
Every modeling-family source file needs a matching test file under tests/models/.
| Default | Enabled |
| Scope | All models |
| Source | mlinter/trf038.py |
| Show in terminal | mlinter --rule TRF038 |
What it does
Checks that every modeling_*.py, processing_*.py, image_processing_*.py, video_processing_*.py, feature_extraction_*.py and tokenization_*.py file has a matching tests/models/<model>/test_*.py (modeling_acme.py -> tests/models/acme/test_modeling_acme.py). Exempt: configuration_*.py, covered by ConfigTester in the companion test_modeling_*.py, and tokenization_utils*.py, a helper covered through its tokenizer; tokenization_<name>_fast.py maps to its slow counterpart’s test file. A modular_*.py can define several families at once, so its classes are routed by name suffix – XxxModel/XxxPreTrainedModel/XxxFor<Task> modeling, XxxImageProcessor(Fast) image processing, XxxProcessor processing, XxxVideoProcessor video processing, XxxFeatureExtractor feature extraction, XxxTokenizer(Fast) tokenization, XxxConfig skipped – and one violation is reported per missing test file. # trf-ignore: TRF038 is not supported; use allowlist_models so an exemption is visible in review.
Why is this bad?
A source file with no test file has no regression coverage: a broken forward pass, a bad conversion mapping, or a tokenizer that drops a special token can land and stay broken indefinitely. A dummy config with random weights, or a small hand-written vocabulary, is enough to exercise any of them.
Example
src/transformers/models/acme/modeling_acme.py
+tests/models/acme/test_modeling_acme.py
src/transformers/models/acme/tokenization_acme.py
+tests/models/acme/test_tokenization_acme.py
Suppressing this rule
Add a # trf-ignore: TRF038 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
39 models are exempt from TRF038 in mlinter/rules.toml, because they predate the convention and cannot be changed without breaking backward compatibility.
Show the 39 allowlisted models
broscohere_asremu3exaone4_5gemma4glm46vglm_imageglmgagranite_speechhiggs_audio_v2inklingkyutai_speech_to_textlasrminimax_m3_vlmoonshine_streamingnemotron3_5_asrnemotron_asr_streamingnougatpaddleocr_vlpe_audiope_audio_videope_videopi0pp_formulanetrf_detrsam2sam2_videosam3_trackersam3_tracker_videosam3_videosiglipsiglip2tvpvideo_llavaviltvjepa2voxtralvoxtral_realtimex_clip
