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

False-positive unreachable code for empty generator #4698

Closed
cdce8p opened this issue Jul 10, 2021 · 0 comments · Fixed by #4699
Closed

False-positive unreachable code for empty generator #4698

cdce8p opened this issue Jul 10, 2021 · 0 comments · Fixed by #4699
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@cdce8p
Copy link
Member

cdce8p commented Jul 10, 2021

The most efficient way to create a empty generator is to add yield after return. pylint should not add the warning unreachable code for it. https://stackoverflow.com/a/61496399

Steps to reproduce

def func():
    return
    yield

Current behavior

test.py:3:4: W0101: Unreachable code (unreachable)

Expected behavior

No warning

pylint --version output

pylint 2.9.4-dev0
astroid 2.6.3-dev0
Python 3.10.0b3 (v3.10.0b3:865714a117, Jun 17 2021, 09:09:56) [Clang 12.0.5 (clang-1205.0.22.9)]
@cdce8p cdce8p added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Jul 10, 2021
@cdce8p cdce8p self-assigned this Jul 10, 2021
@cdce8p cdce8p added this to the 2.9.4 milestone Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant