TRF040

@can_return_tuple must not be combined with @capture_outputs.

   
Default Enabled
Scope All models
Source mlinter/trf040.py
Show in terminal mlinter --rule TRF040

What it does

In modeling_*.py and modular_*.py, checks methods decorated with both @capture_outputs and @can_return_tuple. Complements TRF003, which covers manual return_dict branching in forward().

Why is this bad?

@capture_outputs and @can_return_tuple both pop return_dict, thus only the outermost decorator sees the true value. @capture_outputs already handles to_tuple conversion which makes @can_return_tuple redundant.

Example

-@can_return_tuple
 @merge_with_config_defaults
 @capture_outputs
 @auto_docstring
 def forward(self, x):
     return AcmeModelOutput(last_hidden_state=x)

Suppressing this rule

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