astral-sh/ruff

Which bare tuples are in scope for COM818?

Open

#18,851 创建于 2025年6月21日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)Rust (47,527 star) (2,088 fork)batch import
documentationhelp wantedrule

描述

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)

贡献者指南