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

Update unncessary-regular-expression (RUF055) fix to use var == value #14733

Closed
zanieb opened this issue Dec 2, 2024 · 3 comments · Fixed by #15605
Closed

Update unncessary-regular-expression (RUF055) fix to use var == value #14733

zanieb opened this issue Dec 2, 2024 · 3 comments · Fixed by #15605
Assignees
Labels
help wanted Contributions especially welcome preview Related to preview mode features rule Implementing or modifying a lint rule

Comments

@zanieb
Copy link
Member

zanieb commented Dec 2, 2024

I think this should be s == "abc". It's a minor stylistic difference (in which I think x == VALUE is more idiomatic), but it can cause actual differences due to type checking implementations, e.g. microsoft/pyright#9093

Originally posted by @zanieb in #14659 (comment)

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule help wanted Contributions especially welcome preview Related to preview mode features labels Dec 2, 2024
@MichaReiser
Copy link
Member

MichaReiser commented Dec 2, 2024

Thanks for opening an issue. I should have done it for you but I forgot :(

@kiran-4444
Copy link
Contributor

I'd like to work on this.

@MichaReiser
Copy link
Member

Go for it. Let me know if you need any help.

ntBre pushed a commit that referenced this issue Jan 21, 2025
This commit fixes RUF055 rule to format `re.fullmatch(pattern, var)` to
`var == pattern` instead of the current `pattern == var` behaviour. This
is more idiomatic and easy to understand.

## Summary

This changes the current formatting behaviour of `re.fullmatch(pattern,
var)` to format it to `var == pattern` instead of `pattern == var`.

## Test Plan

I used a code file locally to see the updated formatting behaviour.

Fixes #14733
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions especially welcome preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants