You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What you are doing looks very cool and could be helpful to me and a lot of people.
However, the examples from the readme do not work for me (I have tried mypy with python3.10 and python3.11)
For example, with this one:
from typing import Any
import numpy as np
from phantom_tensors import parse
from phantom_tensors.numpy import NDArray
from phantom_tensors.alphabet import A, B # these are just NewType(..., int) types
def func_on_2d(x: NDArray[Any, Any]): ...
def func_on_3d(x: NDArray[Any, Any, Any]): ...
def func_on_any_arr(x: np.ndarray): ...
# runtime: ensures shape of arr_3d matches (A, B, A) patterns
arr_3d = parse(np.ones((3, 5, 3)), NDArray[A, B, A])
func_on_2d(arr_3d) # static type checker: Error! # expects 2D arr, got 3D
func_on_3d(arr_3d) # static type checker: OK
func_on_any_arr(arr_3d) # static type checker: OK
I get the following errors:
phan_tensor_test.py:11: error: "NDArray" expects no type arguments, but 2 given [type-arg]
phan_tensor_test.py:12: error: "NDArray" expects no type arguments, but 3 given [type-arg]
phan_tensor_test.py:15: error: The type "Type[NDArray]" is not generic and not indexable [misc]
I am not deep enough into python-typing to understand how this issue could be related to a misconfiguration. I know variadic generics are a very recent feature, which is why I tried to run it with python 3.11 but it still showed this error.
I am using the latest pypi-version of your library (I did not clone your repo)
The text was updated successfully, but these errors were encountered:
julian-goettingen
changed the title
Example does not pass mypy-checks for me
Examples fail mypy-checks in unexpected ways
May 25, 2023
What you are doing looks very cool and could be helpful to me and a lot of people.
However, the examples from the readme do not work for me (I have tried mypy with python3.10 and python3.11)
For example, with this one:
I get the following errors:
I am not deep enough into python-typing to understand how this issue could be related to a misconfiguration. I know variadic generics are a very recent feature, which is why I tried to run it with python 3.11 but it still showed this error.
I am using the latest pypi-version of your library (I did not clone your repo)
The text was updated successfully, but these errors were encountered: