Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUF031 fix introduces a syntax error when the tuple contains a slice #12766

Closed
dscorbett opened this issue Aug 8, 2024 · 1 comment · Fixed by #12768
Closed

RUF031 fix introduces a syntax error when the tuple contains a slice #12766

dscorbett opened this issue Aug 8, 2024 · 1 comment · Fixed by #12768
Assignees
Labels
bug Something isn't working

Comments

@dscorbett
Copy link

The fix for RUF031 introduces a syntax error when lint.ruff.parenthesize-tuple-in-subscript = true and the subscripted tuple contains a slice.

$ ruff --version
ruff 0.5.7
$ cat ruf031.py
x[:,]
$ ruff check --isolated --preview --select RUF031 --config 'lint.ruff.parenthesize-tuple-in-subscript = true' ruf031.py --fix

error: Fix introduced a syntax error. Reverting all changes.

This indicates a bug in Ruff. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BFix%20error%5D

...quoting the contents of `ruf031.py`, the rule codes RUF031, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

ruf031.py:1:3: RUF031 Use parentheses for tuples in subscripts.
  |
1 | x[:,]
  |   ^^ RUF031
  |
  = help: Parenthesize the tuple.

Found 1 error.
[*] 1 fixable with the `--fix` option.
@dylwil3
Copy link
Collaborator

dylwil3 commented Aug 8, 2024

Thanks! I'll take a stab at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants