Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrays interpreted as "Any" #8

Closed
tmansuripur opened this issue Jan 6, 2020 · 2 comments
Closed

Arrays interpreted as "Any" #8

tmansuripur opened this issue Jan 6, 2020 · 2 comments

Comments

@tmansuripur
Copy link

I have a testmodule.py file containing:

import numpy as np
from nptyping import Array

def testfunc(a: Array[float,10]) -> int:
    c = a + 'astring' # add an array to a string, should cause error
    b = np.array([1,2,3]) # should cause an error because function expects int output
    reveal_locals()
    return b

The mypy output on this file is:

testmodule.py:1: error: No library stub file for module 'numpy'
testmodule.py:1: note: (Stub files are from https://github.com/python/typeshed)
testmodule.py:2: error: Cannot find implementation or library stub for module named 'nptyping'
testmodule.py:2: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
testmodule.py:7: note: Revealed local types are:
testmodule.py:7: note: a: Any
testmodule.py:7: note: b: Any
testmodule.py:7: note: c: Any

Are a, b, and c interpreted as Any because I have done something wrong (perhaps by not having a stub file for nptyping?) or is there a deeper issue?

Thank you for your help, and for developing type hints for numpy.

@ramonhagenaars
Copy link
Owner

Hi tmansuripur.

You're not doing anything wrong, mypy is just not supported by nptyping (yet). 🙂

@ramonhagenaars
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants