If a class is added in pyflyby global imports and in the class defn itself if the class is referenced via type-hints, tidy-imports wrongly suggests to add the import.
Reproducer:
> cat /var/tmp/test.py
from __future__ import annotations
class _TestCls():
class WrappedFunction():
pass
class Popen():
def test(self) -> Popen:
return None
> tidy-imports /var/tmp/test.py
[PYFLYBY] /var/tmp/test.py: added 'from subprocess import Popen'
--- /var/tmp/test.py 2024-03-12 11:39:26.907800081 -0400
+++ /tmp/tmpdmys0zsi 2024-03-12 11:39:32.834774372 -0400
@@ -1,4 +1,5 @@
from __future__ import annotations
+from subprocess import Popen
class _TestCls():
class WrappedFunction():
Replace /var/tmp/test.py? [y/N]
But the same type hints doesn't suggest for imports if the extra class is not present but the type-hints exist.
> cat /var/tmp/test.py
from __future__ import annotations
class Popen():
def test(self) -> Popen:
return None
> tidy-imports /var/tmp/test.py
>
If a class is added in pyflyby global imports and in the class defn itself if the class is referenced via type-hints, tidy-imports wrongly suggests to add the import.
Reproducer:
But the same type hints doesn't suggest for imports if the extra class is not present but the type-hints exist.