-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Closed
Copy link
Milestone
Description
Describe the issue:
The type signatures for ndarray.squeeze and ndarray.transpose don't allow passing None for the first argument, but the actual code allows it.
Reproduce the code example:
import numpy as np
print(np.ones((1,2,3)).squeeze(None).shape)
print(np.ones((1,2,3)).transpose(None).shape)Error message:
~/Desktop> python a.py
(2, 3)
(3, 2, 1)
~/Desktop> mypy a.py
a.py:2: error: Argument 1 to "squeeze" of "ndarray" has incompatible type "None"; expected "Union[SupportsIndex, Tuple[SupportsIndex, ...]]"
a.py:3: error: No overload variant of "transpose" of "ndarray" matches argument type "None"
a.py:3: note: Possible overload variants:
a.py:3: note: def transpose(self, Union[SupportsIndex, Sequence[SupportsIndex]]) -> ndarray[Any, dtype[floating[_64Bit]]]
a.py:3: note: def transpose(self, *axes: SupportsIndex) -> ndarray[Any, dtype[floating[_64Bit]]]NumPy/Python version information:
1.22.3 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:06:49)
[Clang 12.0.1 ]