I want to add type hint to a method that accepts a 2D array of following possible types int, unsigned int, float, double. How to add type hint for this?
If it is about only say int, I can write following which works:
from typing import NoReturn
from nptyping import NDArray, Shape, Int
def foo(arr: NDArray[Shape["*, *"], Int]) -> NoReturn:
pass
When I try to extend it using Union like following, it does not work:
from typing import NoReturn, Union
from nptyping import NDArray, Shape, Int, UInt, Float32, Float64
def foo(arr: NDArray[Shape["*, *"], Union[Int, UInt, Float32, Float64]]) -> NoReturn:
pass
I want to avoid using Any.