We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Consider the following Python code:
def opposite(a: bool) -> bool: if a: return False else: return True
When I run ruff on the code with the SIM checks selected, the suggested replacement returns the opposite of the expected value.
% ruff check --isolated --select SIM --show-source sim103.py sim103.py:2:5: SIM103 Return the condition `a` directly | 1 | def opposite(a: bool) -> bool: 2 | if a: | _____^ 3 | | return False 4 | | else: 5 | | return True | |___________________^ SIM103 | = help: Replace with `return a`
If I switch False and True in the code, the suggested replacement remains the same, but is then correct.
False
True
% ruff --version ruff 0.1.14
Playground link: https://play.ruff.rs/7d91158b-0d65-4cc1-95f3-435136f0d1e9
The text was updated successfully, but these errors were encountered:
Seems related to #2037 but IIUC that only disabled the autofix, but didn't fix the suggestion.
Sorry, something went wrong.
Ah thanks -- that does look like a bug.
I'll re-enable the fix, and insert the correct code and suggestion.
flake8-simplify
needless-bool
SIM103
[flake8-simplify] Support inverted returns in needless-bool (`SIM…
47b8a89
…103`) (#9619) Closes #9618.
Fixed in the next release, thanks!
Thanks for the quick fix!
charliermarsh
Successfully merging a pull request may close this issue.
Consider the following Python code:
When I run ruff on the code with the SIM checks selected, the suggested replacement returns the opposite of the expected value.
If I switch
False
andTrue
in the code, the suggested replacement remains the same, but is then correct.Playground link: https://play.ruff.rs/7d91158b-0d65-4cc1-95f3-435136f0d1e9
The text was updated successfully, but these errors were encountered: