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

[flake8-pie] Remove following comma correctly when the unpacked dictionary is empty (PIE800) #16008

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

InSyncWithFoo
Copy link
Contributor

Summary

Resolves #15997.

Ruff used to introduce syntax errors while fixing these cases, but no longer will:

{"a": [], **{},}
#         ^^^^ Removed, leaving two contiguous commas

{"a": [], **({})}
#         ^^^^^ Removed, leaving a stray closing parentheses

Previously, the function would take a shortcut if the unpacked dictionary is empty; now, both cases are handled using the same logic introduced in #15394. This change slightly modifies that logic to also remove the first comma following the dictionary, if and only if it is empty.

Test Plan

cargo nextest run and cargo insta test.

@InSyncWithFoo
Copy link
Contributor Author

The diff is best viewed with whitespace changes hidden.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser added bug Something isn't working fixes Related to suggested fixes for violations labels Feb 7, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Thanks and hiding whitespace was an excellent suggestion!

@MichaReiser MichaReiser merged commit bb979e0 into astral-sh:main Feb 7, 2025
21 checks passed
@InSyncWithFoo InSyncWithFoo deleted the PIE800 branch February 7, 2025 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PIE800 fix introduces a syntax error for {**{},}
2 participants