diff options
| -rw-r--r-- | numpy/__init__.pyi | 11 | ||||
| -rw-r--r-- | numpy/typing/tests/data/reveal/scalars.py | 6 |
2 files changed, 15 insertions, 2 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 2c043608f..3e2d79776 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -3273,8 +3273,15 @@ class void(flexible): def setfield( self, val: ArrayLike, dtype: DTypeLike, offset: int = ... ) -> None: ... - def __getitem__(self, key: SupportsIndex) -> Any: ... - def __setitem__(self, key: SupportsIndex, value: ArrayLike) -> None: ... + @overload + def __getitem__(self, key: str | SupportsIndex) -> Any: ... + @overload + def __getitem__(self, key: list[str]) -> void: ... + def __setitem__( + self, + key: str | List[str] | SupportsIndex, + value: ArrayLike, + ) -> None: ... void0 = void diff --git a/numpy/typing/tests/data/reveal/scalars.py b/numpy/typing/tests/data/reveal/scalars.py index e83d579e9..a95f8f6f2 100644 --- a/numpy/typing/tests/data/reveal/scalars.py +++ b/numpy/typing/tests/data/reveal/scalars.py @@ -10,6 +10,7 @@ c16: np.complex128 m: np.timedelta64 U: np.str_ S: np.bytes_ +V: np.void reveal_type(c8.real) # E: {float32} reveal_type(c8.imag) # E: {float32} @@ -36,6 +37,11 @@ reveal_type(c16.imag) # E: {float64} reveal_type(np.unicode_('foo')) # E: numpy.str_ reveal_type(np.str0('foo')) # E: numpy.str_ +reveal_type(V[0]) # E: Any +reveal_type(V["field1"]) # E: Any +reveal_type(V[["field1", "field2"]]) # E: numpy.void +V[0] = 5 + # Aliases reveal_type(np.unicode_()) # E: numpy.str_ reveal_type(np.str0()) # E: numpy.str_ |
