Skip to content

[pyupgrade] make fix unsafe if it deletes comments (UP010, unnecessary-future-import) #18291

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

Merged
merged 2 commits into from
May 25, 2025

Conversation

chirizxc
Copy link
Contributor

@chirizxc chirizxc commented May 24, 2025

/closes #18282

Summary

The unnecessary-future-import (UP010) fix should be marked as unsafe when it deletes a comment on the same line as the import. Currently, the fix removes the entire line including comments, which may cause unintended code/comment loss. This change ensures that such fixes are flagged as unsafe and require manual review.

Test Plan

@MichaReiser MichaReiser added the fixes Related to suggested fixes for violations label May 25, 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.

Thank you

Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser merged commit be76fad into astral-sh:main May 25, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixes Related to suggested fixes for violations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UP010 fix should be unsafe when it deletes a comment
2 participants