pyflakes
pyflakes copied to clipboard
fix: support type annotation of recursive data structure in local scope
Hi everyone ! This is my first contribution so the whole code is still pretty new to me. While working on pydantic, I encountered a false positive and saw there was already an opened issue. I hence decided to give it a go!
closes #567
Ok so I ran this against a bunch of typed code, I can't really explain this difference but I boiled this down from a change in pandas:
from typing import TYPE_CHECKING
from typing import Union
if TYPE_CHECKING:
from x import Y
def f():
x: Union[int, "Y"]
if f:
from x import Y
return Y()
Before this produced no errors, but after your PR it produces the following:
$ python3 -m pyflakes t.py
t.py:5:5 'x.Y' imported but unused
t.py:11:9 redefinition of unused 'Y' from line 5
via #754