Using the mypy's master branch (219fbf890bfbeb03e8720083f4b5850f7fa81636) and pip installing https://github.com/numpy/numpy-stubs (a PEP 561 package), running `mypy` on the following code: ```python import numpy as np def f(x: np.ndarray): reveal_type(x) ``` outputs: ``` test.py:4: error: Revealed type is 'Any' ``` But if I do: ```python from numpy import ndarray def f(x: ndarray): reveal_type(x) ``` then I get the expected ``` test.py:4: error: Revealed type is 'numpy.ndarray' ```
Activity
alanhdu commentedon Jul 7, 2018
Note that this example works perfectly fine with
mypy 0.610. I ran a git bisect and believe that d91efd4 introduced the current behavior.emmatyping commentedon Jul 8, 2018
Confirmed the bisect, and it is happening on master.
The issue is this part here: https://github.com/python/mypy/blob/master/mypy/semanal.py#L3081. It appears that adding the
__getattr__check is too earnest, it does not allow for re-binding that occurs on line 3098.