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

SIM103: Unnecessary if-else to return boolean #3

Closed
MartinThoma opened this issue Sep 21, 2020 · 1 comment
Closed

SIM103: Unnecessary if-else to return boolean #3

MartinThoma opened this issue Sep 21, 2020 · 1 comment

Comments

@MartinThoma
Copy link
Owner

Rule

Do not use an if-else block when you can directly return the condition.

Example

# Bad
if condition:
    return True
else
    return False

# Good
return bool(condition)
@MartinThoma MartinThoma changed the title New Rule: Unnecessary if-else to return boolean SIM103: Unnecessary if-else to return boolean Jan 7, 2021
@tolomea
Copy link

tolomea commented Jul 5, 2022

The description here is good, but the actual implementation suggests using "return condition" instead which is behaviour changing.
Similarly the suggestion for "return not not condition" is "return condition" which is also behaviour changing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants