Skip to content

Commit e7382bc

Browse files
authored
đź’„reformat dtype.__new__ (#482)
1 parent a72a046 commit e7382bc

File tree

1 file changed

+30
-139
lines changed

1 file changed

+30
-139
lines changed

‎src/numpy-stubs/__init__.pyi

Lines changed: 30 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ _ExpiredAttribute: TypeAlias = L[
730730
_UFuncMethod: TypeAlias = L["__call__", "reduce", "reduceat", "accumulate", "outer", "at"]
731731

732732
_2Tuple: TypeAlias = tuple[_T, _T]
733+
_MetaData: TypeAlias = dict[str, Any]
733734

734735
_JustSignedInteger: TypeAlias = _nt.Just[signedinteger]
735736
_JustUnsignedInteger: TypeAlias = _nt.Just[unsignedinteger]
@@ -1142,220 +1143,110 @@ class dtype(Generic[_ScalarT_co], metaclass=_DTypeMeta):
11421143
#
11431144
@overload
11441145
def __new__(
1145-
cls,
1146-
dtype: _nt.ToDTypeBool,
1147-
align: py_bool = False,
1148-
copy: py_bool = False,
1149-
metadata: dict[str, Any] = ...,
1146+
cls, dtype: _nt.ToDTypeBool, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
11501147
) -> dtype[bool_]: ...
11511148
@overload
11521149
def __new__(
1153-
cls,
1154-
dtype: _nt.ToDTypeInt8,
1155-
align: py_bool = False,
1156-
copy: py_bool = False,
1157-
metadata: dict[str, Any] = ...,
1150+
cls, dtype: _nt.ToDTypeInt8, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
11581151
) -> dtype[int8]: ...
11591152
@overload
11601153
def __new__(
1161-
cls,
1162-
dtype: _nt.ToDTypeUInt8,
1163-
align: py_bool = False,
1164-
copy: py_bool = False,
1165-
metadata: dict[str, Any] = ...,
1154+
cls, dtype: _nt.ToDTypeUInt8, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
11661155
) -> dtype[uint8]: ...
11671156
@overload
11681157
def __new__(
1169-
cls,
1170-
dtype: _nt.ToDTypeInt16,
1171-
align: py_bool = False,
1172-
copy: py_bool = False,
1173-
metadata: dict[str, Any] = ...,
1158+
cls, dtype: _nt.ToDTypeInt16, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
11741159
) -> dtype[int16]: ...
11751160
@overload
11761161
def __new__(
1177-
cls,
1178-
dtype: _nt.ToDTypeUInt16,
1179-
align: py_bool = False,
1180-
copy: py_bool = False,
1181-
metadata: dict[str, Any] = ...,
1162+
cls, dtype: _nt.ToDTypeUInt16, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
11821163
) -> dtype[uint16]: ...
11831164
@overload
11841165
def __new__(
1185-
cls,
1186-
dtype: _nt.ToDTypeInt32,
1187-
align: py_bool = False,
1188-
copy: py_bool = False,
1189-
metadata: dict[str, Any] = ...,
1166+
cls, dtype: _nt.ToDTypeInt32, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
11901167
) -> dtype[int32]: ...
11911168
@overload
11921169
def __new__(
1193-
cls,
1194-
dtype: _nt.ToDTypeUInt32,
1195-
align: py_bool = False,
1196-
copy: py_bool = False,
1197-
metadata: dict[str, Any] = ...,
1170+
cls, dtype: _nt.ToDTypeUInt32, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
11981171
) -> dtype[uint32]: ...
11991172
@overload
12001173
def __new__(
1201-
cls,
1202-
dtype: type[ct.c_long] | _LongCodes,
1203-
align: py_bool = False,
1204-
copy: py_bool = False,
1205-
metadata: dict[str, Any] = ...,
1174+
cls, dtype: type[ct.c_long] | _LongCodes, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12061175
) -> dtype[long]: ...
12071176
@overload
12081177
def __new__(
1209-
cls,
1210-
dtype: type[ct.c_ulong] | _ULongCodes,
1211-
align: py_bool = False,
1212-
copy: py_bool = False,
1213-
metadata: dict[str, Any] = ...,
1178+
cls, dtype: type[ct.c_ulong] | _ULongCodes, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12141179
) -> dtype[ulong]: ...
12151180
@overload
12161181
def __new__(
1217-
cls,
1218-
dtype: _nt.ToDTypeInt64,
1219-
align: py_bool = False,
1220-
copy: py_bool = False,
1221-
metadata: dict[str, Any] = ...,
1182+
cls, dtype: _nt.ToDTypeInt64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12221183
) -> dtype[int64]: ...
12231184
@overload
12241185
def __new__(
1225-
cls,
1226-
dtype: _nt.ToDTypeUInt64,
1227-
align: py_bool = False,
1228-
copy: py_bool = False,
1229-
metadata: dict[str, Any] = ...,
1186+
cls, dtype: _nt.ToDTypeUInt64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12301187
) -> dtype[uint64]: ...
12311188
@overload
12321189
def __new__(
1233-
cls,
1234-
dtype: _nt.ToDTypeFloat16,
1235-
align: py_bool = False,
1236-
copy: py_bool = False,
1237-
metadata: dict[str, Any] = ...,
1190+
cls, dtype: _nt.ToDTypeFloat16, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12381191
) -> dtype[float16]: ...
12391192
@overload
12401193
def __new__(
1241-
cls,
1242-
dtype: _nt.ToDTypeFloat32,
1243-
align: py_bool = False,
1244-
copy: py_bool = False,
1245-
metadata: dict[str, Any] = ...,
1194+
cls, dtype: _nt.ToDTypeFloat32, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12461195
) -> dtype[float32]: ...
12471196
@overload
12481197
def __new__(
1249-
cls,
1250-
dtype: _nt.ToDTypeFloat64 | None,
1251-
align: py_bool = False,
1252-
copy: py_bool = False,
1253-
metadata: dict[str, Any] = ...,
1198+
cls, dtype: _nt.ToDTypeFloat64 | None, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12541199
) -> dtype[float64]: ...
12551200
@overload
12561201
def __new__(
1257-
cls,
1258-
dtype: _nt.ToDTypeLongDouble,
1259-
align: py_bool = False,
1260-
copy: py_bool = False,
1261-
metadata: dict[str, Any] = ...,
1202+
cls, dtype: _nt.ToDTypeLongDouble, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12621203
) -> dtype[longdouble]: ...
1263-
@overload # `complexfloating` string-based representations
1204+
@overload
12641205
def __new__(
1265-
cls,
1266-
dtype: _nt.ToDTypeComplex64,
1267-
align: py_bool = False,
1268-
copy: py_bool = False,
1269-
metadata: dict[str, Any] = ...,
1206+
cls, dtype: _nt.ToDTypeComplex64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12701207
) -> dtype[complex64]: ...
12711208
@overload
12721209
def __new__(
1273-
cls,
1274-
dtype: _nt.ToDTypeComplex128,
1275-
align: py_bool = False,
1276-
copy: py_bool = False,
1277-
metadata: dict[str, Any] = ...,
1210+
cls, dtype: _nt.ToDTypeComplex128, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12781211
) -> dtype[complex128]: ...
12791212
@overload
12801213
def __new__(
1281-
cls,
1282-
dtype: _nt.ToDTypeCLongDouble,
1283-
align: py_bool = False,
1284-
copy: py_bool = False,
1285-
metadata: dict[str, Any] = ...,
1214+
cls, dtype: _nt.ToDTypeCLongDouble, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12861215
) -> dtype[clongdouble]: ...
12871216
@overload
12881217
def __new__(
1289-
cls,
1290-
dtype: _nt.ToDTypeObject,
1291-
align: py_bool = False,
1292-
copy: py_bool = False,
1293-
metadata: dict[str, Any] = ...,
1218+
cls, dtype: _nt.ToDTypeObject, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
12941219
) -> dtype[object_]: ...
12951220
@overload
12961221
def __new__(
1297-
cls,
1298-
dtype: _nt.ToDTypeBytes,
1299-
align: py_bool = False,
1300-
copy: py_bool = False,
1301-
metadata: dict[str, Any] = ...,
1222+
cls, dtype: _nt.ToDTypeBytes, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
13021223
) -> dtype[bytes_]: ...
13031224
@overload
13041225
def __new__( # type: ignore[overload-overlap]
1305-
cls,
1306-
dtype: _nt.ToDTypeStr,
1307-
align: py_bool = False,
1308-
copy: py_bool = False,
1309-
metadata: dict[str, Any] = ...,
1226+
cls, dtype: _nt.ToDTypeStr, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
13101227
) -> dtype[str_]: ...
13111228
@overload
13121229
def __new__(
1313-
cls,
1314-
dtype: _nt.ToDTypeVoid,
1315-
align: py_bool = False,
1316-
copy: py_bool = False,
1317-
metadata: dict[str, Any] = ...,
1230+
cls, dtype: _nt.ToDTypeVoid, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
13181231
) -> dtype[void]: ...
13191232
@overload
13201233
def __new__(
1321-
cls,
1322-
dtype: _nt.ToDTypeDateTime64,
1323-
align: py_bool = False,
1324-
copy: py_bool = False,
1325-
metadata: dict[str, Any] = ...,
1234+
cls, dtype: _nt.ToDTypeDateTime64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
13261235
) -> dtype[datetime64]: ...
13271236
@overload
13281237
def __new__(
1329-
cls,
1330-
dtype: _nt.ToDTypeTimeDelta64,
1331-
align: py_bool = False,
1332-
copy: py_bool = False,
1333-
metadata: dict[str, Any] = ...,
1238+
cls, dtype: _nt.ToDTypeTimeDelta64, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
13341239
) -> dtype[timedelta64]: ...
13351240
@overload
13361241
def __new__(
1337-
cls,
1338-
dtype: _nt.ToDTypeString,
1339-
align: py_bool = False,
1340-
copy: py_bool = False,
1341-
metadata: dict[str, Any] = ...,
1242+
cls, dtype: _nt.ToDTypeString, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
13421243
) -> dtypes.StringDType: ...
13431244
@overload
13441245
def __new__(
1345-
cls,
1346-
dtype: _DTypeLike[_ScalarT_co],
1347-
align: py_bool = False,
1348-
copy: py_bool = False,
1349-
metadata: dict[str, Any] = ...,
1246+
cls, dtype: _DTypeLike[_ScalarT_co], align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...
13501247
) -> Self: ...
13511248
@overload
1352-
def __new__(
1353-
cls,
1354-
dtype: DTypeLike,
1355-
align: py_bool = False,
1356-
copy: py_bool = False,
1357-
metadata: dict[str, Any] = ...,
1358-
) -> dtype: ...
1249+
def __new__(cls, dtype: DTypeLike, align: py_bool = False, copy: py_bool = False, metadata: _MetaData = ...) -> dtype: ...
13591250

13601251
#
13611252
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
@@ -1438,7 +1329,7 @@ class _ArrayOrScalarCommon:
14381329

14391330
#
14401331
@property
1441-
def __array_interface__(self) -> dict[str, Any]: ...
1332+
def __array_interface__(self) -> _MetaData: ...
14421333
@property
14431334
def __array_priority__(self) -> float: ...
14441335
@property

0 commit comments

Comments
 (0)