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

Add autofix for RUF039 #14527

Closed
AlexWaygood opened this issue Nov 22, 2024 · 5 comments · Fixed by #14536
Closed

Add autofix for RUF039 #14527

AlexWaygood opened this issue Nov 22, 2024 · 5 comments · Fixed by #14536
Assignees
Labels
fixes Related to suggested fixes for violations help wanted Contributions especially welcome

Comments

@AlexWaygood
Copy link
Member

The newly added preview rule RUF039 doesn't have an autofix. It would be very convenient if it had one, since it's otherwise quite a noisy rule.

@AlexWaygood AlexWaygood added fixes Related to suggested fixes for violations help wanted Contributions especially welcome labels Nov 22, 2024
@MichaReiser
Copy link
Member

At least for the common cases. Conversions to raw strings can be tricky if backslashes are involved

@MichaReiser
Copy link
Member

Or a fix involving backslashes at least needs to be unsafe because

>>> re.compile("\n\r\t").pattern == re.compile(r"\n\r\t").pattern
False
>>> re.compile("\n\r\t").pattern
'\n\r\t'
>>> re.compile(r"\n\r\t").pattern
'\\n\\r\\t'

@AlexWaygood
Copy link
Member Author

AlexWaygood commented Nov 22, 2024

Yeah. But even an autofix just for strings that don't have any backslashes in them would make things much more ergonomic. E.g. none of the strings that I had to manually edit in python-trio/trio#3143 had any backslashes in them.

@dylwil3
Copy link
Collaborator

dylwil3 commented Nov 22, 2024

@AlexWaygood feel free to reopen if you'd like to encourage a second pass on this with more extensive auto-fixing!

@AlexWaygood
Copy link
Member Author

Thanks! 😃 I think this is going to take care of most of the noise as-is, so I'm happy to leave it there for now unless we get requests from users for fixes in more cases 👍

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 help wanted Contributions especially welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants