TRF019
A processor TypedDict class must not define _defaults, instead push them upstream to the hub (processor_config.json).
| Default | Enabled |
| Scope | Models added on or after 2026-06-20 |
| Source | mlinter/trf019.py |
| Show in terminal | mlinter --rule TRF019 |
What it does
Checks that *ProcessorKwargs TypedDict classes in processing_*.py files do not set a non-empty _defaults dict. Old models released before cutoff date are not checked against the rule for backwards compatibility; new models must not hardcode defaults in Python.
Why is this bad?
Hardcoding defaults in _defaults scatters processor configuration across Python source files, makes it unintuitive when it comes to overriding defaults via config, and bloats up the code. The canonical home for processor defaults is processor_config.json on the hub, which is shipped with the checkpoint and can be updated without touching code.
Example
class Gemma4ProcessorKwargs(ProcessingKwargs, total=False):
- _defaults = {
- "text_kwargs": {"padding": False},
- "images_kwargs": {"return_tensors": "pt"},
- }
images_kwargs: Gemma4ImageProcessorKwargs
Suppressing this rule
Add a # trf-ignore: TRF019 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.
