astral-sh/ruff

Which bare tuples are in scope for COM818?

Open

Aperta il 21 giu 2025

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Rust (47.527 star) (2088 fork)batch import
documentationhelp wantedrule

Descrizione

Summary

trailing-comma-on-bare-tuple (COM818) is documented as:

Checks for the presence of trailing commas on bare (i.e., unparenthesized) tuples.

but it only checks for a comma before a statement-final newline. The documentation should be more precise as to which bare tuples are in scope for this rule.

Bare tuples in subscripts are subject to incorrectly-parenthesized-tuple-in-subscript (RUF031). They are out of scope for COM818.

COM818 does not check bare tuples in yield expressions. Maybe it should, or maybe this should be called out as another exception in the documentation.

def f(x): x.append((yield x[-1],))

COM818 should also check for a comma before a semicolon, as in this bare tuple:

print("Hello,"),;

Version

ruff 0.12.0 (87f0feb21 2025-06-17)

Guida contributor