-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
SIM103 return condition directly incorrect error message #10843
Labels
question
Asking for support or clarification
Comments
IronCore864
changed the title
SIM103 return condition directly bug
SIM103 return condition directly incorrect error message
Apr 9, 2024
In general, you can replace: if condition:
return False
return True With: return not condition So in your case, it could be: return not (keys is not None and notice.key not in keys) Or, simplified: return keys is None or notice.key in keys |
I think the OP is pointing out that the diagnostic message sort of implies you can replace the code with |
Makes sense -- I'll invert it. |
Glyphack
pushed a commit
to Glyphack/ruff
that referenced
this issue
Apr 12, 2024
## Summary Closes astral-sh#10843.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have searched SIM103 in the open issues and didn't find anything related, so creating this one.
It seems the error message/prompt for SIM103 can be incorrect in some cases.
My code base is quite large, but if I copy the single function out for testing, I could not reproduce. It only happens on the large code base:
I think the prompt/error message is not correct. How could:
be replaced by
return condition
? The message should be something like "return not condition instead", not "return condition instead". If the user copy/paste the suggestion it'd be wrong.Only
can be replaced directly by
return condition
instead.With latest ruff version 0.3.5.
The text was updated successfully, but these errors were encountered: