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

mypy, isinstance, and generics, oh my! #108

Open
ewa opened this issue May 30, 2023 · 0 comments
Open

mypy, isinstance, and generics, oh my! #108

ewa opened this issue May 30, 2023 · 0 comments

Comments

@ewa
Copy link

ewa commented May 30, 2023

I don't know if this is user error or a bug, but when I try to typecheck the following code (basically copied from USERDOC.md) with mypy I get an error:

The code:

print(isinstance(np.random.randn(5, 2), NDArray[Shape["5 coordinates, [x, y]"], Any]))

The error

% mypy error_example.py
error_example.py:5: error: Parameterized generics cannot be used with class or instance checks  [misc]
Found 1 error in 1 file (checked 1 source file)

Does anyone have any suggestions?

Here's my configuration info:

ewa-mbp:~/ext/sounder andersoe % pip3 list | grep nptyping
nptyping                   2.5.0
ewa-mbp:~/ext/sounder andersoe % pip3 list | grep mypy
mypy                       1.3.0
mypy-extensions            1.0.0
ewa-mbp:~/ext/sounder andersoe % pip3 list | grep numpy
numpy                      1.24.3
ewa-mbp:~/ext/sounder andersoe % python3 --version
Python 3.11.3

The full code examples is:

import numpy as np
from typing import Any
from nptyping import NDArray, Shape

print(isinstance(np.random.randn(5, 2), NDArray[Shape["5 coordinates, [x, y]"], Any]))
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

1 participant