Open
Description
Reproducer:
test.py
from module import *
x,y = get_num_threads, heaviside
module.py
from typing import Any
import numpy
from numpy import *
heaviside: numpy.ufunc
def get_num_threads(*args, **kwargs) -> Any: ...
def set_num_threads(*args, **kwargs) -> Any: ...
test.py runs fine without tidy-imports
$ python test.py
Ran tidy-imports with --replace-star-imports
> tidy-imports --replace-star-imports test.py
[PYFLYBY] test.py: replaced 'from module import *' with 2 imports
[PYFLYBY] test.py: removed unused 'from module import set_num_threads'
[PYFLYBY] test.py:3: undefined name 'heaviside' and no known import for it
--- /test.py 2022-11-01 17:45:38.701542000 +0530
+++ /tmp/tmpn8t6r9e3 2022-11-01 17:46:01.109807168 +0530
@@ -1,3 +1,3 @@
-from module import *
+from module import get_num_threads
x,y = get_num_threads, heaviside
Replace test.py? [y/N] y
[PYFLYBY] test.py: *** modified ***
As we can see heaviside import was never added.
> python test.py
Traceback (most recent call last):
File "test.py", line 3, in <module>
x,y = get_num_threads, heaviside
NameError: name 'heaviside' is not defined