-
Notifications
You must be signed in to change notification settings - Fork 590
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
use _yield from []_ to create empty generator when needed #2572 #2581
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Please add bug fixes, new features, breaking changes and anything else you think is worthwhile mentioning to the master (unreleased)
section of CHANGELOG.md. If no CHANGELOG update is needed add the following to the PR description: [x] No CHANGELOG update needed
CHANGELOG updated or no update needed, thanks! 😄
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.
use yield from [] to create empty generator when needed #2572
the old pattern was originally used to support Python 2.7 which didn't have |
@dhruvak001 are there any other parts of the codebase with a similar pattern that needs updating? |
@williballenthin i don't think so as far as I have seen. |
@williballenthin can u please review it? |
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.
looks good. please address the linter failures.
@williballenthin plz check out the above PR in capa-rules for linter failures update. |
code style/black is failing. would you please fix the python file formatting? |
c287ff9
to
3f36e59
Compare
All Done @williballenthin |
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.
please update the submodule back to master@capa-rules can we can merge this.
@williballenthin updated the submodule to the again the master @capa-rules, but again the rule linter check failed. |
thats expected at the moment and won't be a blocker here. the issues are unrelated to the changes in this PR. |
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 @dhruvak001!
our linters fail in master due to the hex casing changes in this PR: i will revert those changes |
The issue#2572 arises from an old trick of making a function behave as a generator by using if False: yield .... The correct and idiomatic solution is to replace such patterns with yield from [], which is clean, efficient, and easy to understand.