summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@gmail.com>2021-01-29 06:16:50 +0000
committerGitHub <noreply@github.com>2021-01-29 06:16:50 +0000
commitf42b5a01c8e82dee90d08fd470a16b2fe957fa14 (patch)
tree3ca4dafbc69a95e6f8f13de8442730f232e99f1c
parentb74ee9ff8f0c3be41dfbd1bd5a10f54e67c40f39 (diff)
parent7060d5e28f735199df6b465755ddd1d3bc7ed07e (diff)
downloadnumpy-f42b5a01c8e82dee90d08fd470a16b2fe957fa14.tar.gz
Merge pull request #18229 from BvB93/__all__
MAINT: Clean up all module-level dunders
-rw-r--r--numpy/__init__.pyi158
-rw-r--r--numpy/typing/tests/data/fail/modules.py4
-rw-r--r--numpy/typing/tests/data/pass/modules.py20
-rw-r--r--numpy/typing/tests/data/reveal/modules.py5
4 files changed, 87 insertions, 100 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index 3d92a543b..911b496df 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -159,66 +159,66 @@ else:
# Ensures that the stubs are picked up
from numpy import (
- char,
- ctypeslib,
- emath,
- fft,
- lib,
- linalg,
- ma,
- matrixlib,
- polynomial,
- random,
- rec,
- testing,
- version,
+ char as char,
+ ctypeslib as ctypeslib,
+ emath as emath,
+ fft as fft,
+ lib as lib,
+ linalg as linalg,
+ ma as ma,
+ matrixlib as matrixlib,
+ polynomial as polynomial,
+ random as random,
+ rec as rec,
+ testing as testing,
+ version as version,
)
from numpy.core.function_base import (
- linspace,
- logspace,
- geomspace,
+ linspace as linspace,
+ logspace as logspace,
+ geomspace as geomspace,
)
from numpy.core.fromnumeric import (
- take,
- reshape,
- choose,
- repeat,
- put,
- swapaxes,
- transpose,
- partition,
- argpartition,
- sort,
- argsort,
- argmax,
- argmin,
- searchsorted,
- resize,
- squeeze,
- diagonal,
- trace,
- ravel,
- nonzero,
- shape,
- compress,
- clip,
- sum,
- all,
- any,
- cumsum,
- ptp,
- amax,
- amin,
- prod,
- cumprod,
- ndim,
- size,
- around,
- mean,
- std,
- var,
+ take as take,
+ reshape as reshape,
+ choose as choose,
+ repeat as repeat,
+ put as put,
+ swapaxes as swapaxes,
+ transpose as transpose,
+ partition as partition,
+ argpartition as argpartition,
+ sort as sort,
+ argsort as argsort,
+ argmax as argmax,
+ argmin as argmin,
+ searchsorted as searchsorted,
+ resize as resize,
+ squeeze as squeeze,
+ diagonal as diagonal,
+ trace as trace,
+ ravel as ravel,
+ nonzero as nonzero,
+ shape as shape,
+ compress as compress,
+ clip as clip,
+ sum as sum,
+ all as all,
+ any as any,
+ cumsum as cumsum,
+ ptp as ptp,
+ amax as amax,
+ amin as amin,
+ prod as prod,
+ cumprod as cumprod,
+ ndim as ndim,
+ size as size,
+ around as around,
+ mean as mean,
+ std as std,
+ var as var,
)
from numpy.core._asarray import (
@@ -311,52 +311,10 @@ from numpy.core.shape_base import (
vstack as vstack,
)
-# Add an object to `__all__` if their stubs are defined in an external file;
-# their stubs will not be recognized otherwise.
-# NOTE: This is redundant for objects defined within this file.
-__all__ = [
- "linspace",
- "logspace",
- "geomspace",
- "take",
- "reshape",
- "choose",
- "repeat",
- "put",
- "swapaxes",
- "transpose",
- "partition",
- "argpartition",
- "sort",
- "argsort",
- "argmax",
- "argmin",
- "searchsorted",
- "resize",
- "squeeze",
- "diagonal",
- "trace",
- "ravel",
- "nonzero",
- "shape",
- "compress",
- "clip",
- "sum",
- "all",
- "any",
- "cumsum",
- "ptp",
- "amax",
- "amin",
- "prod",
- "cumprod",
- "ndim",
- "size",
- "around",
- "mean",
- "std",
- "var",
-]
+__all__: List[str]
+__path__: List[str]
+__version__: str
+__git_version__: str
DataSource: Any
MachAr: Any
diff --git a/numpy/typing/tests/data/fail/modules.py b/numpy/typing/tests/data/fail/modules.py
index 5e2d820ab..b80fd9ede 100644
--- a/numpy/typing/tests/data/fail/modules.py
+++ b/numpy/typing/tests/data/fail/modules.py
@@ -8,3 +8,7 @@ np.warnings # E: Module has no attribute
np.sys # E: Module has no attribute
np.os # E: Module has no attribute
np.math # E: Module has no attribute
+
+np.__NUMPY_SETUP__ # E: Module has no attribute
+np.__deprecated_attrs__ # E: Module has no attribute
+np.__expired_functions__ # E: Module has no attribute
diff --git a/numpy/typing/tests/data/pass/modules.py b/numpy/typing/tests/data/pass/modules.py
new file mode 100644
index 000000000..013841ae7
--- /dev/null
+++ b/numpy/typing/tests/data/pass/modules.py
@@ -0,0 +1,20 @@
+import numpy as np
+
+np.char
+np.ctypeslib
+np.emath
+np.fft
+np.lib
+np.linalg
+np.ma
+np.matrixlib
+np.polynomial
+np.random
+np.rec
+np.testing
+np.version
+
+np.__all__
+np.__path__
+np.__version__
+np.__git_version__
diff --git a/numpy/typing/tests/data/reveal/modules.py b/numpy/typing/tests/data/reveal/modules.py
index 406463152..8e4eab50f 100644
--- a/numpy/typing/tests/data/reveal/modules.py
+++ b/numpy/typing/tests/data/reveal/modules.py
@@ -18,3 +18,8 @@ reveal_type(np.version) # E: ModuleType
# TODO: Remove when annotations have been added to `np.testing.assert_equal`
reveal_type(np.testing.assert_equal) # E: Any
+
+reveal_type(np.__all__) # E: list[builtins.str]
+reveal_type(np.__path__) # E: list[builtins.str]
+reveal_type(np.__version__) # E: str
+reveal_type(np.__git_version__) # E: str