TRF064

<Model>ProcessorKwargs must not override _defaults, text_kwargs, images_kwargs, videos_kwargs or audio_kwargs. Set defaults as class attributes of the processor instead.

   
Default Enabled
Scope All models
Source mlinter/trf064.py
Show in terminal mlinter --rule TRF064

What it does

In processing_*.py and modular_*.py, flags a ProcessingKwargs subclass that assigns or re-annotates _defaults, text_kwargs, images_kwargs, videos_kwargs or audio_kwargs in its class body.

Why is this bad?

ProcessingKwargs._defaults is deprecated. Processor defaults are class attributes of the ProcessorMixin subclass, where they are inherited and overridden like any other attribute. The modality fields cannot be statically typed as available arguments are only known at runtime due to dynamic processor loading. We omit typing them and stick to the default types.

Example

 class AcmeProcessorKwargs(ProcessingKwargs, total=False):
-    images_kwargs: AcmeImagesKwargs
-    _defaults = {
-        "text_kwargs": {"padding": False},
-        "images_kwargs": {"num_crops": 4},
-    }
+    num_crops: int


 class AcmeProcessor(ProcessorMixin):
     valid_processor_kwargs = AcmeProcessorKwargs
+    text_kwargs = {"padding": False}
+    num_crops: int = 4

Suppressing this rule

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

5 models are exempt from TRF064 in mlinter/rules.toml, because they predate the convention and cannot be changed without breaking backward compatibility.

Show the 5 allowlisted models
  • csm
  • dia
  • emu3
  • pocket_tts
  • voxtral