Skip to content

Commit 8b0f975

Browse files
committed
TYP: Fill in the missing __all__ exports
1 parent 6f5dd58 commit 8b0f975

Some content is hidden

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

56 files changed

+2146
-745
lines changed

numpy/_core/defchararray.pyi

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ from numpy import (
2020
_ShapeType_co,
2121
_SupportsBuffer,
2222
)
23-
2423
from numpy._typing import (
2524
NDArray,
2625
_Shape,
@@ -30,8 +29,63 @@ from numpy._typing import (
3029
_ArrayLikeInt_co as i_co,
3130
_ArrayLikeBool_co as b_co,
3231
)
33-
34-
from numpy._core.multiarray import compare_chararrays as compare_chararrays
32+
from numpy._core.multiarray import compare_chararrays
33+
34+
__all__ = [
35+
"equal",
36+
"not_equal",
37+
"greater_equal",
38+
"less_equal",
39+
"greater",
40+
"less",
41+
"str_len",
42+
"add",
43+
"multiply",
44+
"mod",
45+
"capitalize",
46+
"center",
47+
"count",
48+
"decode",
49+
"encode",
50+
"endswith",
51+
"expandtabs",
52+
"find",
53+
"index",
54+
"isalnum",
55+
"isalpha",
56+
"isdigit",
57+
"islower",
58+
"isspace",
59+
"istitle",
60+
"isupper",
61+
"join",
62+
"ljust",
63+
"lower",
64+
"lstrip",
65+
"partition",
66+
"replace",
67+
"rfind",
68+
"rindex",
69+
"rjust",
70+
"rpartition",
71+
"rsplit",
72+
"rstrip",
73+
"split",
74+
"splitlines",
75+
"startswith",
76+
"strip",
77+
"swapcase",
78+
"title",
79+
"translate",
80+
"upper",
81+
"zfill",
82+
"isnumeric",
83+
"isdecimal",
84+
"array",
85+
"asarray",
86+
"compare_chararrays",
87+
"chararray",
88+
]
3589

3690
_SCT = TypeVar("_SCT", bound=str_ | bytes_)
3791
_CharDType_co = TypeVar(
@@ -457,7 +511,6 @@ class chararray(ndarray[_ShapeType_co, _CharDType_co]):
457511
def isnumeric(self) -> ndarray[_ShapeType_co, dtype[np.bool]]: ...
458512
def isdecimal(self) -> ndarray[_ShapeType_co, dtype[np.bool]]: ...
459513

460-
__all__: list[str]
461514

462515
# Comparison
463516
@overload

numpy/_core/einsumfunc.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ from numpy._typing import (
2020
_DTypeLikeObject,
2121
)
2222

23+
__all__ = ["einsum", "einsum_path"]
24+
2325
_ArrayType = TypeVar(
2426
"_ArrayType",
2527
bound=NDArray[np.bool | number[Any]],
@@ -29,7 +31,6 @@ _OptimizeKind: TypeAlias = bool | Literal["greedy", "optimal"] | Sequence[Any] |
2931
_CastingSafe: TypeAlias = Literal["no", "equiv", "safe", "same_kind"]
3032
_CastingUnsafe: TypeAlias = Literal["unsafe"]
3133

32-
__all__: list[str]
3334

3435
# TODO: Properly handle the `casting`-based combinatorics
3536
# TODO: We need to evaluate the content `__subscripts` in order

numpy/_core/fromnumeric.pyi

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,53 @@ from numpy._typing import (
5454
_ScalarLike_co,
5555
)
5656

57+
__all__ = [
58+
"all",
59+
"amax",
60+
"amin",
61+
"any",
62+
"argmax",
63+
"argmin",
64+
"argpartition",
65+
"argsort",
66+
"around",
67+
"choose",
68+
"clip",
69+
"compress",
70+
"cumprod",
71+
"cumsum",
72+
"cumulative_prod",
73+
"cumulative_sum",
74+
"diagonal",
75+
"mean",
76+
"max",
77+
"min",
78+
"matrix_transpose",
79+
"ndim",
80+
"nonzero",
81+
"partition",
82+
"prod",
83+
"ptp",
84+
"put",
85+
"ravel",
86+
"repeat",
87+
"reshape",
88+
"resize",
89+
"round",
90+
"searchsorted",
91+
"shape",
92+
"size",
93+
"sort",
94+
"squeeze",
95+
"std",
96+
"sum",
97+
"swapaxes",
98+
"take",
99+
"trace",
100+
"transpose",
101+
"var",
102+
]
103+
57104
_SCT = TypeVar("_SCT", bound=generic)
58105
_SCT_uifcO = TypeVar("_SCT_uifcO", bound=number[Any] | object_)
59106
_ArrayType = TypeVar("_ArrayType", bound=np.ndarray[Any, Any])
@@ -72,8 +119,6 @@ _PyArray: TypeAlias = list[_T] | tuple[_T, ...]
72119
# `int` also covers `bool`
73120
_PyScalar: TypeAlias = int | float | complex | bytes | str
74121

75-
__all__: list[str]
76-
77122
@overload
78123
def take(
79124
a: _ArrayLike[_SCT],

numpy/_core/function_base.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ from numpy._typing import (
1515
_ArrayLikeComplex_co,
1616
)
1717

18-
_SCT = TypeVar("_SCT", bound=generic)
18+
__all__ = ["logspace", "linspace", "geomspace"]
1919

20-
__all__: list[str]
20+
_SCT = TypeVar("_SCT", bound=generic)
2121

2222
@overload
2323
def linspace(

numpy/_core/getlimits.pyi

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from numpy import (
2-
finfo as finfo,
3-
iinfo as iinfo,
4-
)
1+
from numpy import finfo, iinfo
52

6-
__all__: list[str]
3+
__all__ = ["finfo", "iinfo"]

numpy/_core/memmap.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from numpy import memmap as memmap
1+
from numpy import memmap
22

3-
__all__: list[str]
3+
__all__ = ["memmap"]

numpy/_core/multiarray.pyi

Lines changed: 134 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ from typing import (
77
Any,
88
TypeAlias,
99
overload,
10-
TypeAlias,
1110
TypeVar,
1211
TypedDict,
1312
SupportsIndex,
@@ -17,16 +16,24 @@ from typing import (
1716
ClassVar,
1817
type_check_only,
1918
)
20-
from typing_extensions import Unpack
19+
from typing_extensions import CapsuleType, Unpack
2120

2221
import numpy as np
2322
from numpy import ( # type: ignore[attr-defined]
2423
# Re-exports
25-
busdaycalendar as busdaycalendar,
26-
broadcast as broadcast,
27-
dtype as dtype,
28-
ndarray as ndarray,
29-
nditer as nditer,
24+
busdaycalendar,
25+
broadcast,
26+
correlate,
27+
count_nonzero,
28+
dtype,
29+
einsum as c_einsum,
30+
flatiter,
31+
from_dlpack,
32+
interp,
33+
matmul,
34+
ndarray,
35+
nditer,
36+
vecdot,
3037

3138
# The rest
3239
ufunc,
@@ -52,6 +59,7 @@ from numpy import ( # type: ignore[attr-defined]
5259
_NDIterFlagsKind,
5360
_NDIterOpFlagsKind,
5461
)
62+
from numpy.lib._array_utils_impl import normalize_axis_index
5563

5664
from numpy._typing import (
5765
# Shapes
@@ -91,6 +99,98 @@ from numpy._typing._ufunc import (
9199
_PyFunc_Nin1P_Nout2P,
92100
)
93101

102+
__all__ = [
103+
"_ARRAY_API",
104+
"ALLOW_THREADS",
105+
"BUFSIZE",
106+
"CLIP",
107+
"DATETIMEUNITS",
108+
"ITEM_HASOBJECT",
109+
"ITEM_IS_POINTER",
110+
"LIST_PICKLE",
111+
"MAXDIMS",
112+
"MAY_SHARE_BOUNDS",
113+
"MAY_SHARE_EXACT",
114+
"NEEDS_INIT",
115+
"NEEDS_PYAPI",
116+
"RAISE",
117+
"USE_GETITEM",
118+
"USE_SETITEM",
119+
"WRAP",
120+
"_flagdict",
121+
"from_dlpack",
122+
"_place",
123+
"_reconstruct",
124+
"_vec_string",
125+
"_monotonicity",
126+
"add_docstring",
127+
"arange",
128+
"array",
129+
"asarray",
130+
"asanyarray",
131+
"ascontiguousarray",
132+
"asfortranarray",
133+
"bincount",
134+
"broadcast",
135+
"busday_count",
136+
"busday_offset",
137+
"busdaycalendar",
138+
"can_cast",
139+
"compare_chararrays",
140+
"concatenate",
141+
"copyto",
142+
"correlate",
143+
"correlate2",
144+
"count_nonzero",
145+
"c_einsum",
146+
"datetime_as_string",
147+
"datetime_data",
148+
"dot",
149+
"dragon4_positional",
150+
"dragon4_scientific",
151+
"dtype",
152+
"empty",
153+
"empty_like",
154+
"error",
155+
"flagsobj",
156+
"flatiter",
157+
"format_longfloat",
158+
"frombuffer",
159+
"fromfile",
160+
"fromiter",
161+
"fromstring",
162+
"get_handler_name",
163+
"get_handler_version",
164+
"inner",
165+
"interp",
166+
"interp_complex",
167+
"is_busday",
168+
"lexsort",
169+
"matmul",
170+
"vecdot",
171+
"may_share_memory",
172+
"min_scalar_type",
173+
"ndarray",
174+
"nditer",
175+
"nested_iters",
176+
"normalize_axis_index",
177+
"packbits",
178+
"promote_types",
179+
"putmask",
180+
"ravel_multi_index",
181+
"result_type",
182+
"scalar",
183+
"set_datetimeparse_function",
184+
"set_typeDict",
185+
"shares_memory",
186+
"typeinfo",
187+
"unpackbits",
188+
"unravel_index",
189+
"vdot",
190+
"where",
191+
"zeros",
192+
]
193+
94194
_T_co = TypeVar("_T_co", covariant=True)
95195
_T_contra = TypeVar("_T_contra", contravariant=True)
96196
_SCT = TypeVar("_SCT", bound=generic)
@@ -257,8 +357,34 @@ class _ConstructorEmpty(Protocol):
257357
**kwargs: Unpack[_KwargsEmpty],
258358
) -> NDArray[Any]: ...
259359

360+
error: Final = Exception
260361

261-
__all__: list[str]
362+
# from ._multiarray_umath
363+
ITEM_HASOBJECT: Final[L[1]]
364+
LIST_PICKLE: Final[L[2]]
365+
ITEM_IS_POINTER: Final[L[4]]
366+
NEEDS_INIT: Final[L[8]]
367+
NEEDS_PYAPI: Final[L[16]]
368+
USE_GETITEM: Final[L[32]]
369+
USE_SETITEM: Final[L[64]]
370+
DATETIMEUNITS: Final[CapsuleType]
371+
_ARRAY_API: Final[CapsuleType]
372+
_flagdict: Final[dict[str, int]]
373+
_monotonicity: Final[Callable[..., object]]
374+
_place: Final[Callable[..., object]]
375+
_reconstruct: Final[Callable[..., object]]
376+
_vec_string: Final[Callable[..., object]]
377+
correlate2: Final[Callable[..., object]]
378+
dragon4_positional: Final[Callable[..., object]]
379+
dragon4_scientific: Final[Callable[..., object]]
380+
interp_complex: Final[Callable[..., object]]
381+
set_datetimeparse_function: Final[Callable[..., object]]
382+
def get_handler_name(a: NDArray[Any] = ..., /) -> str | None: ...
383+
def get_handler_version(a: NDArray[Any] = ..., /) -> int | None: ...
384+
def format_longfloat(x: np.longdouble, precision: int) -> str: ...
385+
def scalar(dtype: _DType, object: bytes | object = ...) -> ndarray[tuple[()], _DType]: ...
386+
def set_typeDict(dict_: dict[str, np.dtype[Any]], /) -> None: ...
387+
typeinfo: Final[dict[str, np.dtype[np.generic]]]
262388

263389
ALLOW_THREADS: Final[int] # 0 or 1 (system-specific)
264390
BUFSIZE: L[8192]

0 commit comments

Comments
 (0)