Skip to content

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

Merged
AlexWaygood merged 3 commits into
astral-sh:mainfrom
dylwil3:ruf031-slice-in-subscript
Aug 9, 2024
Merged

AlexWaygood merged 3 commits into
astral-sh:mainfrom
dylwil3:ruf031-slice-in-subscript

Conversation

@dylwil3

@dylwil3 dylwil3 commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator

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

dylwil3 commented Aug 9, 2024

Copy link
Copy Markdown
Collaborator Author

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

@charliermarsh charliermarsh added the bug An issue describing something that isn't working, or a PR that fixes a bug label Aug 9, 2024
@charliermarsh

Copy link
Copy Markdown
Member

Thanks @dylwil3!

@github-actions

github-actions Bot commented Aug 9, 2024 •

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@AlexWaygood

Copy link
Copy Markdown
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
@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 An issue describing something that isn't working, or a PR that fixes a bug

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