deshaw / pyflyby

A set of productivity tools for Python
https://deshaw.github.io/pyflyby/
Other
347 stars 52 forks source link

False positive warning `undefined name 'foo' and no known import for it` in structural pattern matching of dict #347

Closed Atry closed 2 months ago

Atry commented 2 months ago

Given the following pyflyby_bug.py file:

match { "foo": 1, "bar": 2 }:
    case {
        "foo": foo,
        "bar": bar,
        **rest,
    }:
        print(foo)
    case _:
        pass

When running:

tidy-imports pyflyby_bug.py

I got the warning:

[PYFLYBY] /home/nixos/peftai/pyflyby_bug.py:7: undefined name 'foo' and no known import for it

version

tidy-imports --version
pyflyby 1.9.4 (tidy-imports)
Carreau commented 2 months ago

This should have been fixed by #349