Skip to content

False-positive unreachable code for empty generator #4698

@cdce8p

Description

@cdce8p

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)]

Metadata

Metadata

Assignees

Labels

False Positive 🦟A message is emitted but nothing is wrong with the code

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions