-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Simplify boolean return logic #14012
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, but several of these make the code less readable. In general, some of these sequences of if conditions are pretty subtle and it's much easier to read them one at a time than to have them compressed into a single statement. I've commented on the ones I think are worthwhile, if you want to pursue this PR, please remove the others :-)
Okay, I think I got all of them. |
I fixed the existing changes and added a few more. All the new changes are pretty small, and they can be kept or not. In the spirit of simplified boolean logic, it would be easier if you mark the ones to reject, rather than the ones to keep 😄 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, reviewed the new changes. Please don't add any others in this PR :-)
Co-authored-by: Shantanu <[email protected]>
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thanks for reviewing! |
I was poking around in the code and I noticed that there are a lot of bare boolean returns. For example:
This can be simplified to:
That's a pretty simple case. Other cases are more complicated, but similar in spirit.
This is a refactoring PR that should not change any behavior. By my count it results in a net reduction of 32
return
statements.If this sort of change is welcome, I can keep going.