Skip to content

Incorrect detection of unused variables in generators #1670

@PabloRuizCuevas

Description

@PabloRuizCuevas

Describe the Bug

Some generators with send incorrectly report that sent variables are unused

from typing import Generator, cast

def test() -> Generator[float, float]:
    """absolute difference first last step"""
    new = yield None
    while True:
        new = yield new - 1  # `Variable `new` is unusedPyrefly(unused-variable)`

This can't be seen in the sandbox, but in vs code

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    UserBugs reported by external users that should be prioritised

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions