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

[ruff] Skip tuples with slice expressions in incorrectly-parenthesized-tuple-in-subscript (RUF031) #12768

Merged
merged 3 commits into from
Aug 9, 2024

Conversation

dylwil3
Copy link
Collaborator

@dylwil3 dylwil3 commented Aug 9, 2024

Summary

Adding parentheses to a tuple in a subscript with elements that include slice expressions causes a syntax error. For example, d[(1,2,:)] is a syntax error.

So, when lint.ruff.parenthesize-tuple-in-subscript = true and the tuple includes a slice expression, we skip this check and fix.

Closes #12766.

@dylwil3
Copy link
Collaborator Author

dylwil3 commented Aug 9, 2024

Probably should wait until #12762 is merged in and the subsequent merge conflicts have been resolved.

@charliermarsh charliermarsh added the bug Something isn't working label Aug 9, 2024
@charliermarsh
Copy link
Member

Thanks @dylwil3!

Copy link
Contributor

github-actions bot commented Aug 9, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@AlexWaygood
Copy link
Member

The fix being applied in this PR is very specific. But I think that's okay, because I think this syntax error can only occur due to the very specific details of literal slices inside subscripts. So I don't think the bug report reveals a deeper underlying issue that we need to fix.

@AlexWaygood AlexWaygood enabled auto-merge (squash) August 9, 2024 09:21
@AlexWaygood AlexWaygood merged commit 64f1f34 into astral-sh:main Aug 9, 2024
19 checks passed
@dylwil3 dylwil3 deleted the ruf031-slice-in-subscript branch August 15, 2024 02:44
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
Development

Successfully merging this pull request may close these issues.

RUF031 fix introduces a syntax error when the tuple contains a slice
4 participants