Skip to content

Commit ba80d0a

Browse files
authored
Move __all__ to PEP-8 recommended location (#683)
Module level "dunders" (i.e. names with two leading and two trailing underscores) such as __all__, __author__, __version__, etc. should be placed after the module docstring but before any import statements except from __future__ imports. Python mandates that future-imports must appear in the module before any other code except docstrings. Signed-off-by: nstarman <nstarman@users.noreply.github.com>
1 parent caf1011 commit ba80d0a

18 files changed

+197
-197
lines changed

src/array_api_stubs/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
from . import _2021_12, _2022_12, _draft
2-

src/array_api_stubs/_draft/_types.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@
66
"""
77
from __future__ import annotations
88

9+
__all__ = [
10+
"Any",
11+
"List",
12+
"Literal",
13+
"NestedSequence",
14+
"Optional",
15+
"PyCapsule",
16+
"SupportsBufferProtocol",
17+
"SupportsDLPack",
18+
"Tuple",
19+
"Union",
20+
"Sequence",
21+
"array",
22+
"device",
23+
"dtype",
24+
"ellipsis",
25+
"finfo_object",
26+
"iinfo_object",
27+
"Enum",
28+
]
29+
930
from dataclasses import dataclass
1031
from typing import (
1132
Any,
@@ -34,21 +55,25 @@
3455
@dataclass
3556
class finfo_object:
3657
"""Dataclass returned by `finfo`."""
58+
3759
bits: int
3860
eps: float
3961
max: float
4062
min: float
4163
smallest_normal: float
4264
dtype: dtype
4365

66+
4467
@dataclass
4568
class iinfo_object:
4669
"""Dataclass returned by `iinfo`."""
70+
4771
bits: int
4872
max: int
4973
min: int
5074
dtype: dtype
5175

76+
5277
_T_co = TypeVar("_T_co", covariant=True)
5378

5479

@@ -58,25 +83,3 @@ def __getitem__(self, key: int, /) -> Union[_T_co, NestedSequence[_T_co]]:
5883

5984
def __len__(self, /) -> int:
6085
...
61-
62-
63-
__all__ = [
64-
"Any",
65-
"List",
66-
"Literal",
67-
"NestedSequence",
68-
"Optional",
69-
"PyCapsule",
70-
"SupportsBufferProtocol",
71-
"SupportsDLPack",
72-
"Tuple",
73-
"Union",
74-
"Sequence",
75-
"array",
76-
"device",
77-
"dtype",
78-
"ellipsis",
79-
"finfo_object",
80-
"iinfo_object",
81-
"Enum",
82-
]

src/array_api_stubs/_draft/array_object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
__all__ = ["array"]
4+
35
from ._types import (
46
array,
57
dtype as Dtype,
@@ -1059,5 +1061,3 @@ def to_device(
10591061

10601062

10611063
array = _array
1062-
1063-
__all__ = ["array"]

src/array_api_stubs/_draft/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__all__ = ["e", "inf", "nan", "newaxis", "pi"]
2+
13
e = 2.718281828459045
24
"""
35
IEEE 754 floating-point representation of Euler's constant.
@@ -26,5 +28,3 @@
2628
2729
``pi = 3.1415926535897932384626433...``
2830
"""
29-
30-
__all__ = ["e", "inf", "nan", "newaxis", "pi"]

src/array_api_stubs/_draft/creation_functions.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
__all__ = [
2+
"arange",
3+
"asarray",
4+
"empty",
5+
"empty_like",
6+
"eye",
7+
"from_dlpack",
8+
"full",
9+
"full_like",
10+
"linspace",
11+
"meshgrid",
12+
"ones",
13+
"ones_like",
14+
"tril",
15+
"triu",
16+
"zeros",
17+
"zeros_like",
18+
]
19+
20+
121
from ._types import (
222
List,
323
NestedSequence,
@@ -563,23 +583,3 @@ def zeros_like(
563583
out: array
564584
an array having the same shape as ``x`` and filled with zeros.
565585
"""
566-
567-
568-
__all__ = [
569-
"arange",
570-
"asarray",
571-
"empty",
572-
"empty_like",
573-
"eye",
574-
"from_dlpack",
575-
"full",
576-
"full_like",
577-
"linspace",
578-
"meshgrid",
579-
"ones",
580-
"ones_like",
581-
"tril",
582-
"triu",
583-
"zeros",
584-
"zeros_like",
585-
]

src/array_api_stubs/_draft/data_type_functions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
__all__ = ["astype", "can_cast", "finfo", "iinfo", "isdtype", "result_type"]
2+
3+
14
from ._types import Union, Tuple, array, dtype, finfo_object, iinfo_object
25

36

@@ -208,6 +211,3 @@ def result_type(*arrays_and_dtypes: Union[array, dtype]) -> dtype:
208211
out: dtype
209212
the dtype resulting from an operation involving the input arrays and dtypes.
210213
"""
211-
212-
213-
__all__ = ["astype", "can_cast", "finfo", "iinfo", "isdtype", "result_type"]

src/array_api_stubs/_draft/data_types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
__all__ = ["__eq__"]
2+
3+
14
from ._types import dtype
25

36

@@ -17,6 +20,3 @@ def __eq__(self: dtype, other: dtype, /) -> bool:
1720
out: bool
1821
a boolean indicating whether the data type objects are equal.
1922
"""
20-
21-
22-
__all__ = ["__eq__"]

src/array_api_stubs/_draft/elementwise_functions.py

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
1+
__all__ = [
2+
"abs",
3+
"acos",
4+
"acosh",
5+
"add",
6+
"asin",
7+
"asinh",
8+
"atan",
9+
"atan2",
10+
"atanh",
11+
"bitwise_and",
12+
"bitwise_left_shift",
13+
"bitwise_invert",
14+
"bitwise_or",
15+
"bitwise_right_shift",
16+
"bitwise_xor",
17+
"ceil",
18+
"conj",
19+
"cos",
20+
"cosh",
21+
"divide",
22+
"equal",
23+
"exp",
24+
"expm1",
25+
"floor",
26+
"floor_divide",
27+
"greater",
28+
"greater_equal",
29+
"imag",
30+
"isfinite",
31+
"isinf",
32+
"isnan",
33+
"less",
34+
"less_equal",
35+
"log",
36+
"log1p",
37+
"log2",
38+
"log10",
39+
"logaddexp",
40+
"logical_and",
41+
"logical_not",
42+
"logical_or",
43+
"logical_xor",
44+
"multiply",
45+
"negative",
46+
"not_equal",
47+
"positive",
48+
"pow",
49+
"real",
50+
"remainder",
51+
"round",
52+
"sign",
53+
"sin",
54+
"sinh",
55+
"square",
56+
"sqrt",
57+
"subtract",
58+
"tan",
59+
"tanh",
60+
"trunc",
61+
]
62+
63+
164
from ._types import array
265

366

@@ -2477,66 +2540,3 @@ def trunc(x: array, /) -> array:
24772540
- If ``x_i`` is ``-0``, the result is ``-0``.
24782541
- If ``x_i`` is ``NaN``, the result is ``NaN``.
24792542
"""
2480-
2481-
2482-
__all__ = [
2483-
"abs",
2484-
"acos",
2485-
"acosh",
2486-
"add",
2487-
"asin",
2488-
"asinh",
2489-
"atan",
2490-
"atan2",
2491-
"atanh",
2492-
"bitwise_and",
2493-
"bitwise_left_shift",
2494-
"bitwise_invert",
2495-
"bitwise_or",
2496-
"bitwise_right_shift",
2497-
"bitwise_xor",
2498-
"ceil",
2499-
"conj",
2500-
"cos",
2501-
"cosh",
2502-
"divide",
2503-
"equal",
2504-
"exp",
2505-
"expm1",
2506-
"floor",
2507-
"floor_divide",
2508-
"greater",
2509-
"greater_equal",
2510-
"imag",
2511-
"isfinite",
2512-
"isinf",
2513-
"isnan",
2514-
"less",
2515-
"less_equal",
2516-
"log",
2517-
"log1p",
2518-
"log2",
2519-
"log10",
2520-
"logaddexp",
2521-
"logical_and",
2522-
"logical_not",
2523-
"logical_or",
2524-
"logical_xor",
2525-
"multiply",
2526-
"negative",
2527-
"not_equal",
2528-
"positive",
2529-
"pow",
2530-
"real",
2531-
"remainder",
2532-
"round",
2533-
"sign",
2534-
"sin",
2535-
"sinh",
2536-
"square",
2537-
"sqrt",
2538-
"subtract",
2539-
"tan",
2540-
"tanh",
2541-
"trunc",
2542-
]

src/array_api_stubs/_draft/fft.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
__all__ = [
2+
"fft",
3+
"ifft",
4+
"fftn",
5+
"ifftn",
6+
"rfft",
7+
"irfft",
8+
"rfftn",
9+
"irfftn",
10+
"hfft",
11+
"ihfft",
12+
"fftfreq",
13+
"rfftfreq",
14+
"fftshift",
15+
"ifftshift",
16+
]
17+
118
from ._types import Tuple, Union, Sequence, array, Optional, Literal, device
219

320

@@ -651,21 +668,3 @@ def ifftshift(x: array, /, *, axes: Union[int, Sequence[int]] = None) -> array:
651668
652669
.. versionadded:: 2022.12
653670
"""
654-
655-
656-
__all__ = [
657-
"fft",
658-
"ifft",
659-
"fftn",
660-
"ifftn",
661-
"rfft",
662-
"irfft",
663-
"rfftn",
664-
"irfftn",
665-
"hfft",
666-
"ihfft",
667-
"fftfreq",
668-
"rfftfreq",
669-
"fftshift",
670-
"ifftshift",
671-
]

src/array_api_stubs/_draft/indexing_functions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__all__ = ["take"]
2+
13
from ._types import Union, Optional, array
24

35

@@ -29,6 +31,3 @@ def take(x: array, indices: array, /, *, axis: Optional[int] = None) -> array:
2931
3032
.. versionadded:: 2022.12
3133
"""
32-
33-
34-
__all__ = ["take"]

0 commit comments

Comments
 (0)