diff options
| author | Bas van Beek <43369155+BvB93@users.noreply.github.com> | 2021-06-18 13:10:06 +0200 |
|---|---|---|
| committer | Bas van Beek <43369155+BvB93@users.noreply.github.com> | 2021-06-18 13:24:22 +0200 |
| commit | 2d3205fffc7d9d80c0004c2230969a0f7aae61f6 (patch) | |
| tree | 73018c85c674e7b60089df678a2d8f2696c15bea | |
| parent | 7d8fadac32f102f25642b47e82437f4243ca2658 (diff) | |
| download | numpy-2d3205fffc7d9d80c0004c2230969a0f7aae61f6.tar.gz | |
STY: Use the pipe operator to represent Unions in `np.dtype`
| -rw-r--r-- | numpy/__init__.pyi | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index 7efe73010..bcdf6f8f8 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -897,7 +897,7 @@ _DTypeScalar_co = TypeVar("_DTypeScalar_co", covariant=True, bound=generic) _ByteOrder = L["S", "<", ">", "=", "|", "L", "B", "N", "I"] class dtype(Generic[_DTypeScalar_co]): - names: Optional[Tuple[str, ...]] + names: None | Tuple[str, ...] # Overload for subclass of generic @overload def __new__( @@ -920,7 +920,7 @@ class dtype(Generic[_DTypeScalar_co]): @overload def __new__(cls, dtype: Type[int], align: bool = ..., copy: bool = ...) -> dtype[int_]: ... @overload - def __new__(cls, dtype: Optional[Type[float]], align: bool = ..., copy: bool = ...) -> dtype[float_]: ... + def __new__(cls, dtype: None | Type[float], align: bool = ..., copy: bool = ...) -> dtype[float_]: ... @overload def __new__(cls, dtype: Type[complex], align: bool = ..., copy: bool = ...) -> dtype[complex_]: ... @overload @@ -1051,7 +1051,7 @@ class dtype(Generic[_DTypeScalar_co]): @overload def __getitem__(self: dtype[void], key: List[str]) -> dtype[void]: ... @overload - def __getitem__(self: dtype[void], key: Union[str, int]) -> dtype[Any]: ... + def __getitem__(self: dtype[void], key: str | int) -> dtype[Any]: ... # NOTE: In the future 1-based multiplications will also yield `void` dtypes @overload @@ -1078,11 +1078,11 @@ class dtype(Generic[_DTypeScalar_co]): @property def char(self) -> str: ... @property - def descr(self) -> List[Union[Tuple[str, str], Tuple[str, str, _Shape]]]: ... + def descr(self) -> List[Tuple[str, str] | Tuple[str, str, _Shape]]: ... @property def fields( self, - ) -> Optional[Mapping[str, Union[Tuple[dtype[Any], int], Tuple[dtype[Any], int, Any]]]]: ... + ) -> None | Mapping[str, Tuple[dtype[Any], int] | Tuple[dtype[Any], int, Any]]: ... @property def flags(self) -> int: ... @property @@ -1098,11 +1098,11 @@ class dtype(Generic[_DTypeScalar_co]): @property def kind(self) -> str: ... @property - def metadata(self) -> Optional[Mapping[str, Any]]: ... + def metadata(self) -> None | Mapping[str, Any]: ... @property def name(self) -> str: ... @property - def names(self) -> Optional[Tuple[str, ...]]: ... + def names(self) -> None | Tuple[str, ...]: ... @property def num(self) -> int: ... @property @@ -1110,7 +1110,7 @@ class dtype(Generic[_DTypeScalar_co]): @property def ndim(self) -> int: ... @property - def subdtype(self: _DType) -> Optional[Tuple[_DType, _Shape]]: ... + def subdtype(self: _DType) -> None | Tuple[_DType, _Shape]: ... def newbyteorder(self: _DType, __new_order: _ByteOrder = ...) -> _DType: ... # Leave str and type for end to avoid having to use `builtins.str` # everywhere. See https://github.com/python/mypy/issues/3775 |
