Skip to content

intentionally empty generator marked as unreachable #15345

Closed
@asottile

Description

@asottile

Bug Report

this seems to be a common pattern:

def f() -> Generator[None, None, None]:
    return
    yield

it can instead be rewritten as:

def f() -> Generator[None, None, None]:
    yield from ()

To Reproduce

see above

Expected Behavior

(no errors)

Actual Behavior

$ mypy --warn-unreachable t.py
t.py:5: error: Statement is unreachable  [unreachable]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.3.0
  • Mypy command-line flags: --warn-unreachable
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.10.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-reachabilityDetecting unreachable code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions