astral-sh/ruff

Which bare tuples are in scope for COM818?

Open

#18851 opened on Jun 21, 2025

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Rust (47,527 stars) (2,088 forks)batch import
documentationhelp wantedrule

Description

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)

Contributor guide