Skip to content

RUF031 fix should ensure that a parenthesized single-element tuple has a comma #16077

@dscorbett

Description

@dscorbett

Description

The fix for incorrectly-parenthesized-tuple-in-subscript (RUF031) in Ruff 0.9.6 produces a syntax error when it tries to insert parentheses around a starred expression with no comma.

$ cat >ruf031.py <<'# EOF'
x[*y]
# EOF

$ ruff --isolated check --preview --select RUF031 ruf031.py --config 'lint.ruff.parenthesize-tuple-in-subscript = true' --diff 2>&1 | grep error:
error: Fix introduced a syntax error. Reverting all changes.

The correct fix would be to insert a comma along with the parentheses:

x[(*y,)]

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violationspreviewRelated to preview mode features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions