Skip to content

Commit 51f2a28

Browse files
committed
🎨 reformat for line-length of max 120
1 parent f353db7 commit 51f2a28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+665
-221
lines changed

‎src/_numtype/__init__.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,11 @@ MArray = TypeAliasType("MArray", np.ma.MaskedArray[_ShapeT, np.dtype[_ScalarT0]]
185185
MArray0D = TypeAliasType("MArray0D", np.ma.MaskedArray[tuple[()], np.dtype[_ScalarT0]], type_params=(_ScalarT0,))
186186
MArray1D = TypeAliasType("MArray1D", np.ma.MaskedArray[tuple[int], np.dtype[_ScalarT0]], type_params=(_ScalarT0,))
187187
MArray2D = TypeAliasType("MArray2D", np.ma.MaskedArray[tuple[int, int], np.dtype[_ScalarT0]], type_params=(_ScalarT0,))
188-
MArray3D = TypeAliasType("MArray3D", np.ma.MaskedArray[tuple[int, int, int], np.dtype[_ScalarT0]], type_params=(_ScalarT0,))
188+
MArray3D = TypeAliasType(
189+
"MArray3D",
190+
np.ma.MaskedArray[tuple[int, int, int], np.dtype[_ScalarT0]],
191+
type_params=(_ScalarT0,),
192+
)
189193

190194
Matrix = TypeAliasType("Matrix", np.matrix[tuple[int, int], np.dtype[_ScalarT0]], type_params=(_ScalarT0,))
191195

‎src/_numtype/_nep50.pyi

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ from typing_extensions import TypeAliasType, TypeVar
77

88
import numpy as np
99

10-
__all__ = ["CanCast0D", "CanCastND", "CanNEP50", "CanNEP50Complex", "CanNEP50Float", "MatchND", "PromoteWith", "PromoteWith0D"]
10+
__all__ = [
11+
"CanCast0D",
12+
"CanCastND",
13+
"CanNEP50",
14+
"CanNEP50Complex",
15+
"CanNEP50Float",
16+
"MatchND",
17+
"PromoteWith",
18+
"PromoteWith0D",
19+
]
1120

1221
_T_co = TypeVar("_T_co", covariant=True)
1322
_BelowT_contra = TypeVar("_BelowT_contra", bound=np.generic, contravariant=True)

‎src/_numtype/_scalar_co.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TypeAlias
1+
from typing import Any, TypeAlias
22

33
import numpy as np
44

@@ -37,32 +37,32 @@ __all__ = [
3737
# See https://github.com/numpy/numtype/issues/366 for the scalar promotion table and
3838
# https://numpy.org/neps/nep-0050-scalar-promotion.html for the official specification.
3939

40-
co_integer8: TypeAlias = integer8 | np.bool
41-
co_integer16: TypeAlias = integer16 | co_integer8
42-
co_integer32: TypeAlias = integer32 | co_integer16
43-
co_integer64: TypeAlias = np.integer | np.bool
44-
co_integer = co_integer64
45-
4640
co_int8: TypeAlias = np.int8 | np.bool
4741
co_int16: TypeAlias = np.int16 | co_integer8
4842
co_int32: TypeAlias = np.int32 | co_integer16
4943
co_long: TypeAlias = np.long | co_int32
50-
co_int64: TypeAlias = np.signedinteger | co_integer32
44+
co_int64: TypeAlias = np.signedinteger[Any] | co_integer32
5145

5246
co_uint8: TypeAlias = np.uint8 | np.bool
5347
co_uint16: TypeAlias = np.uint16 | co_uint8
5448
co_uint32: TypeAlias = np.uint32 | co_uint16
5549
co_ulong: TypeAlias = np.ulong | co_uint32
56-
co_uint64: TypeAlias = np.unsignedinteger | np.bool
50+
co_uint64: TypeAlias = np.unsignedinteger[Any] | np.bool
51+
52+
co_integer8: TypeAlias = integer8 | np.bool
53+
co_integer16: TypeAlias = integer16 | co_integer8
54+
co_integer32: TypeAlias = integer32 | co_integer16
55+
co_integer64: TypeAlias = np.integer[Any] | np.bool
56+
co_integer = co_integer64
5757

5858
co_float16: TypeAlias = np.float16 | co_integer8
5959
co_float32: TypeAlias = np.float32 | np.float16 | co_integer16
6060
co_float64: TypeAlias = np.float64 | np.float32 | np.float16 | co_integer64
61-
co_float: TypeAlias = np.floating | co_integer
61+
co_float: TypeAlias = np.floating[Any] | co_integer
6262

6363
co_complex64: TypeAlias = inexact32 | number16 | integer8
6464
co_complex128: TypeAlias = number64 | number32 | number16 | co_integer
65-
co_complex: TypeAlias = np.number | np.bool
65+
co_complex: TypeAlias = np.number[Any] | np.bool
6666
co_number = co_complex
6767

6868
co_timedelta: TypeAlias = np.timedelta64 | co_integer

‎src/numpy-stubs/@test/static/accept/multiarray.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ assert_type(np.frompyfunc(func12, 1, 2).ntypes, int)
147147
assert_type(np.frompyfunc(func12, 1, 2).identity, Any | None)
148148
assert_type(np.frompyfunc(func12, 1, 2).signature, str | None)
149149
assert_type(np.frompyfunc(func12, 1, 2)(f8, f8), tuple[complex, str])
150-
assert_type(np.frompyfunc(func12, 1, 2)(AR_f8, f8), tuple[complex | npt.NDArray[np.object_], str | npt.NDArray[np.object_]])
150+
assert_type(
151+
np.frompyfunc(func12, 1, 2)(AR_f8, f8), tuple[complex | npt.NDArray[np.object_], str | npt.NDArray[np.object_]]
152+
)
151153

152154
assert_type(np.datetime_data("m8[D]"), tuple[str, int])
153155
assert_type(np.datetime_data(np.datetime64), tuple[str, int])

‎src/numpy-stubs/@test/static/accept/scalars.pyi

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
from typing import Any, Literal, TypeAlias
1+
from typing import Any, Literal
22
from typing_extensions import Unpack, assert_type
33

44
import numpy as np
55

6-
_1: TypeAlias = Literal[1] # noqa: PYI042
7-
86
b: np.bool
97
u8: np.uint64
108
i8: np.int64
@@ -111,17 +109,17 @@ assert_type(S.flatten(), np.ndarray[tuple[int], np.dtype[np.bytes_]])
111109

112110
assert_type(b.reshape(()), np.bool)
113111
assert_type(i8.reshape([]), np.int64)
114-
assert_type(b.reshape(1), np.ndarray[tuple[_1], np.dtype[np.bool]])
115-
assert_type(i8.reshape(-1), np.ndarray[tuple[_1], np.dtype[np.int64]])
116-
assert_type(u8.reshape(1, 1), np.ndarray[tuple[_1, _1], np.dtype[np.uint64]])
117-
assert_type(f8.reshape(1, -1), np.ndarray[tuple[_1, _1], np.dtype[np.float64]])
118-
assert_type(c16.reshape(1, 1, 1), np.ndarray[tuple[_1, _1, _1], np.dtype[np.complex128]])
119-
assert_type(U.reshape(1, 1, 1, 1), np.ndarray[tuple[_1, _1, _1, _1], np.dtype[np.str_]])
112+
assert_type(b.reshape(1), np.ndarray[tuple[int], np.dtype[np.bool]])
113+
assert_type(i8.reshape(-1), np.ndarray[tuple[int], np.dtype[np.int64]])
114+
assert_type(u8.reshape(1, 1), np.ndarray[tuple[int, int], np.dtype[np.uint64]])
115+
assert_type(f8.reshape(1, -1), np.ndarray[tuple[int, int], np.dtype[np.float64]])
116+
assert_type(c16.reshape(1, 1, 1), np.ndarray[tuple[int, int, int], np.dtype[np.complex128]])
117+
assert_type(U.reshape(1, 1, 1, 1), np.ndarray[tuple[int, int, int, int], np.dtype[np.str_]])
120118
assert_type(
121119
S.reshape(1, 1, 1, 1, 1),
122120
np.ndarray[
123-
# len(shape) >= 5
124-
tuple[_1, _1, _1, _1, _1, Unpack[tuple[_1, ...]]],
121+
# len(shape) >= 4
122+
tuple[int, int, int, int, Unpack[tuple[int, ...]]],
125123
np.dtype[np.bytes_],
126124
],
127125
)

‎src/numpy-stubs/_core/_dtype.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import numpy as np
88
_T = TypeVar("_T")
99

1010
_Kind: TypeAlias = L["u", "i", "c", "f", "b", "V", "O", "M", "m", "S", "U"]
11-
_Name: TypeAlias = L["uint", "int", "complex", "float", "bool", "void", "object", "datetime", "timedelta", "bytes", "str"]
11+
_Name: TypeAlias = L[
12+
"uint", "int", "complex", "float", "bool", "void", "object", "datetime", "timedelta", "bytes", "str"
13+
]
1214

1315
@type_check_only
1416
class _KindToStemType(TypedDict):

‎src/numpy-stubs/_core/_internal.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class dummy_ctype(Generic[_T_co]):
7070
def __mul__(self, other: object, /) -> Self: ...
7171
def __call__(self, /, *other: object) -> _T_co: ...
7272

73-
def array_ufunc_errmsg_formatter(dummy: object, ufunc: np.ufunc, method: str, *inputs: object, **kwargs: object) -> str: ...
73+
def array_ufunc_errmsg_formatter(
74+
dummy: object, ufunc: np.ufunc, method: str, *inputs: object, **kwargs: object
75+
) -> str: ...
7476
def array_function_errmsg_formatter(public_api: Callable[..., object], types: Iterable[str]) -> str: ...
7577
def npy_ctypes_check(cls: type) -> bool: ...

‎src/numpy-stubs/_core/_multiarray_umath.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ _ShapeT = TypeVar("_ShapeT", bound=tuple[int, ...])
9797

9898
_ScalarT = TypeVar("_ScalarT", bound=np.generic)
9999
_NumericT = TypeVar("_NumericT", bound=np.bool | np.number | np.timedelta64 | np.object_)
100-
_SafeScalarT = TypeVar("_SafeScalarT", bound=np.bool | np.number | np.flexible | np.timedelta64 | np.datetime64) # no `object_`
100+
_SafeScalarT = TypeVar(
101+
"_SafeScalarT", bound=np.bool | np.number | np.flexible | np.timedelta64 | np.datetime64
102+
) # no `object_`
101103

102104
_DTypeT = TypeVar("_DTypeT", bound=np.dtype)
103105

@@ -476,7 +478,9 @@ class nditer:
476478

477479
#
478480
def __enter__(self) -> Self: ...
479-
def __exit__(self, cls: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ...
481+
def __exit__(
482+
self, cls: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None, /
483+
) -> None: ...
480484
def close(self) -> None: ...
481485
def reset(self) -> None: ...
482486

‎src/numpy-stubs/_core/_ufunc_config.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ class errstate:
3838
) -> None: ...
3939
def __call__(self, /, func: _CallableT) -> _CallableT: ...
4040
def __enter__(self) -> None: ...
41-
def __exit__(self, cls: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ...
41+
def __exit__(
42+
self, cls: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None, /
43+
) -> None: ...
4244

4345
def seterr(
4446
all: _ErrKind | None = None,

‎src/numpy-stubs/_core/defchararray.pyi

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ class chararray(np.ndarray[_ShapeT_co, _DTypeT_co]):
272272
@overload
273273
def endswith(self: _StrArray, /, suffix: _ToStrND, start: _ToIntND = 0, end: _ToIntND | None = None) -> _BoolND: ...
274274
@overload
275-
def endswith(self: _BytesArray, /, suffix: _ToBytesND, start: _ToIntND = 0, end: _ToIntND | None = None) -> _BoolND: ...
275+
def endswith(
276+
self: _BytesArray, /, suffix: _ToBytesND, start: _ToIntND = 0, end: _ToIntND | None = None
277+
) -> _BoolND: ...
276278

277279
#
278280
@overload
@@ -320,7 +322,9 @@ class chararray(np.ndarray[_ShapeT_co, _DTypeT_co]):
320322
@overload
321323
def replace(self: _StrArray, /, old: _ToStrND, new: _ToStrND, count: _ToIntND | None = None) -> _StrArray: ...
322324
@overload
323-
def replace(self: _BytesArray, /, old: _ToBytesND, new: _ToBytesND, count: _ToIntND | None = None) -> _BytesArray: ...
325+
def replace(
326+
self: _BytesArray, /, old: _ToBytesND, new: _ToBytesND, count: _ToIntND | None = None
327+
) -> _BytesArray: ...
324328

325329
#
326330
@overload
@@ -369,9 +373,13 @@ class chararray(np.ndarray[_ShapeT_co, _DTypeT_co]):
369373

370374
#
371375
@overload
372-
def startswith(self: _StrArray, /, prefix: _ToStrND, start: _ToIntND = 0, end: _ToIntND | None = None) -> _BoolND: ...
376+
def startswith(
377+
self: _StrArray, /, prefix: _ToStrND, start: _ToIntND = 0, end: _ToIntND | None = None
378+
) -> _BoolND: ...
373379
@overload
374-
def startswith(self: _BytesArray, /, prefix: _ToBytesND, start: _ToIntND = 0, end: _ToIntND | None = None) -> _BoolND: ...
380+
def startswith(
381+
self: _BytesArray, /, prefix: _ToBytesND, start: _ToIntND = 0, end: _ToIntND | None = None
382+
) -> _BoolND: ...
375383

376384
#
377385
@overload
@@ -497,8 +505,14 @@ def asarray( # type: ignore[overload-overlap]
497505
order: _Order | None = None,
498506
) -> _BytesArray: ...
499507
@overload # unicode=False
500-
def asarray(obj: object, itemsize: int | None = None, *, unicode: L[False], order: _Order | None = None) -> _BytesArray: ...
508+
def asarray(
509+
obj: object, itemsize: int | None = None, *, unicode: L[False], order: _Order | None = None
510+
) -> _BytesArray: ...
501511
@overload # unicode=True
502-
def asarray(obj: object, itemsize: int | None = None, *, unicode: L[True], order: _Order | None = None) -> _StrArray: ...
512+
def asarray(
513+
obj: object, itemsize: int | None = None, *, unicode: L[True], order: _Order | None = None
514+
) -> _StrArray: ...
503515
@overload # falback
504-
def asarray(obj: object, itemsize: int | None = None, unicode: bool | None = None, order: _Order | None = None) -> _CharArray: ...
516+
def asarray(
517+
obj: object, itemsize: int | None = None, unicode: bool | None = None, order: _Order | None = None
518+
) -> _CharArray: ...

0 commit comments

Comments
 (0)