ramonhagenaars / nptyping

💡 Type hints for Numpy and Pandas
MIT License
578 stars 29 forks source link

nptyping NDArray cannot be aliased in mypy #33

Closed Chandler closed 4 years ago

Chandler commented 4 years ago
from typing import Any,List
from nptyping import Float32, NDArray

def run1(a: NDArray[(3, Any, Any), Float32]):
    print(a)

Image = NDArray[(3, Any, Any), Float32]

def run2(a: Image): <- exception
    print(a)
bmaps/test.py:15: error: Variable "bmaps.test.Image" is not valid as a type
bmaps/test.py:15: note: See https://mypy.readthedocs.io/en/latest/common_issues.html#variables-vs-type-aliases

When I create this alias mypy thinks it's a type variable, Thanks

Chandler commented 4 years ago

I see...the hints from this library cannot be statically type checked by mypy, they are only there for readability.

ramonhagenaars commented 4 years ago

Another issue has been opened for this. Please refer to #34.