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
  • bros
  • cohere_asr
  • emu3
  • exaone4_5
  • gemma4
  • glm46v
  • glm_image
  • glmga
  • granite_speech
  • higgs_audio_v2
  • inkling
  • kyutai_speech_to_text
  • lasr
  • minimax_m3_vl
  • moonshine_streaming
  • nemotron3_5_asr
  • nemotron_asr_streaming
  • nougat
  • paddleocr_vl
  • pe_audio
  • pe_audio_video
  • pe_video
  • pi0
  • pp_formulanet
  • rf_detr
  • sam2
  • sam2_video
  • sam3_tracker
  • sam3_tracker_video
  • sam3_video
  • siglip
  • siglip2
  • tvp
  • video_llava
  • vilt
  • vjepa2
  • voxtral
  • voxtral_realtime
  • x_clip