summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2020-08-19 14:49:16 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2020-08-19 14:49:16 +0200
commit1ef217b19161e01672e243d21263e517f63d817a (patch)
tree904654692d6cd9705790b02b811d5efaee048e1b
parent64619c55896dad1927afe78c0702a58abf0d038f (diff)
downloadnumpy-1ef217b19161e01672e243d21263e517f63d817a.tar.gz
ENH: Add placeholder stubs for all sub-modules
-rw-r--r--numpy/__init__.pyi37
-rw-r--r--numpy/char.pyi4
-rw-r--r--numpy/compat/__init__.pyi4
-rw-r--r--numpy/core/__init__.pyi4
-rw-r--r--numpy/ctypeslib.pyi4
-rw-r--r--numpy/emath.pyi4
-rw-r--r--numpy/fft/__init__.pyi4
-rw-r--r--numpy/lib/__init__.pyi4
-rw-r--r--numpy/linalg/__init__.pyi4
-rw-r--r--numpy/ma/__init__.pyi4
-rw-r--r--numpy/math.pyi4
-rw-r--r--numpy/matrixlib/__init__.pyi4
-rw-r--r--numpy/os.pyi4
-rw-r--r--numpy/polynomial/__init__.pyi4
-rw-r--r--numpy/random/__init__.pyi4
-rw-r--r--numpy/rec.pyi4
-rw-r--r--numpy/sys.pyi4
-rw-r--r--numpy/testing/__init__.pyi4
-rw-r--r--numpy/tests/typing/reveal/modules.py26
-rw-r--r--numpy/version.pyi4
-rw-r--r--numpy/warnings.pyi4
21 files changed, 132 insertions, 7 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi
index fad5e1774..a1549e2f8 100644
--- a/numpy/__init__.pyi
+++ b/numpy/__init__.pyi
@@ -1,5 +1,5 @@
import builtins
-import sys
+import sys as _sys
import datetime as dt
from abc import abstractmethod
@@ -33,17 +33,40 @@ from typing import (
Union,
)
-if sys.version_info[0] < 3:
+if _sys.version_info[0] < 3:
class SupportsBytes: ...
else:
from typing import SupportsBytes
-if sys.version_info >= (3, 8):
+if _sys.version_info >= (3, 8):
from typing import Literal, Protocol
else:
from typing_extensions import Literal, Protocol
+# Ensures that the stubs are picked up
+from . import (
+ char,
+ compat,
+ core,
+ ctypeslib,
+ emath,
+ fft,
+ lib,
+ linalg,
+ ma,
+ math,
+ matrixlib,
+ os,
+ polynomial,
+ random,
+ rec,
+ sys,
+ testing,
+ version,
+ warnings,
+)
+
# TODO: remove when the full numpy namespace is defined
def __getattr__(name: str) -> Any: ...
@@ -187,7 +210,7 @@ class _ArrayOrScalarCommon(
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __complex__(self) -> complex: ...
- if sys.version_info[0] < 3:
+ if _sys.version_info[0] < 3:
def __oct__(self) -> str: ...
def __hex__(self) -> str: ...
def __nonzero__(self) -> bool: ...
@@ -214,7 +237,7 @@ class _ArrayOrScalarCommon(
def __mul__(self, other): ...
def __rmul__(self, other): ...
def __imul__(self, other): ...
- if sys.version_info[0] < 3:
+ if _sys.version_info[0] < 3:
def __div__(self, other): ...
def __rdiv__(self, other): ...
def __idiv__(self, other): ...
@@ -248,7 +271,7 @@ class _ArrayOrScalarCommon(
def __or__(self, other): ...
def __ror__(self, other): ...
def __ior__(self, other): ...
- if sys.version_info[:2] >= (3, 5):
+ if _sys.version_info[:2] >= (3, 5):
def __matmul__(self, other): ...
def __rmatmul__(self, other): ...
def __neg__(self: _ArraySelf) -> _ArraySelf: ...
@@ -426,7 +449,7 @@ class timedelta64(signedinteger):
@overload
def __add__(self, other: datetime64) -> datetime64: ...
def __sub__(self, other: Union[timedelta64, int]) -> timedelta64: ...
- if sys.version_info[0] < 3:
+ if _sys.version_info[0] < 3:
@overload
def __div__(self, other: timedelta64) -> float: ...
@overload
diff --git a/numpy/char.pyi b/numpy/char.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/char.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/compat/__init__.pyi b/numpy/compat/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/compat/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/core/__init__.pyi b/numpy/core/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/core/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/ctypeslib.pyi b/numpy/ctypeslib.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/ctypeslib.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/emath.pyi b/numpy/emath.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/emath.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/fft/__init__.pyi b/numpy/fft/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/fft/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/lib/__init__.pyi b/numpy/lib/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/lib/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/linalg/__init__.pyi b/numpy/linalg/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/linalg/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/ma/__init__.pyi b/numpy/ma/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/ma/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/math.pyi b/numpy/math.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/math.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/matrixlib/__init__.pyi b/numpy/matrixlib/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/matrixlib/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/os.pyi b/numpy/os.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/os.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/polynomial/__init__.pyi b/numpy/polynomial/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/polynomial/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/random/__init__.pyi b/numpy/random/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/random/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/rec.pyi b/numpy/rec.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/rec.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/sys.pyi b/numpy/sys.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/sys.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/testing/__init__.pyi b/numpy/testing/__init__.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/testing/__init__.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/tests/typing/reveal/modules.py b/numpy/tests/typing/reveal/modules.py
new file mode 100644
index 000000000..b4a94e326
--- /dev/null
+++ b/numpy/tests/typing/reveal/modules.py
@@ -0,0 +1,26 @@
+import numpy as np
+
+reveal_type(np) # E: ModuleType
+
+reveal_type(np.char) # E: ModuleType
+reveal_type(np.compat) # E: ModuleType
+reveal_type(np.core) # E: ModuleType
+reveal_type(np.ctypeslib) # E: ModuleType
+reveal_type(np.emath) # E: ModuleType
+reveal_type(np.fft) # E: ModuleType
+reveal_type(np.lib) # E: ModuleType
+reveal_type(np.linalg) # E: ModuleType
+reveal_type(np.ma) # E: ModuleType
+reveal_type(np.math) # E: ModuleType
+reveal_type(np.matrixlib) # E: ModuleType
+reveal_type(np.os) # E: ModuleType
+reveal_type(np.polynomial) # E: ModuleType
+reveal_type(np.random) # E: ModuleType
+reveal_type(np.rec) # E: ModuleType
+reveal_type(np.sys) # E: ModuleType
+reveal_type(np.testing) # E: ModuleType
+reveal_type(np.version) # E: ModuleType
+reveal_type(np.warnings) # E: ModuleType
+
+# TODO: Remove when annotations have been added to `np.linalg.norm`
+reveal_type(np.linalg.norm) # E: Any
diff --git a/numpy/version.pyi b/numpy/version.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/version.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...
diff --git a/numpy/warnings.pyi b/numpy/warnings.pyi
new file mode 100644
index 000000000..3938d68de
--- /dev/null
+++ b/numpy/warnings.pyi
@@ -0,0 +1,4 @@
+from typing import Any
+
+# TODO: remove when the full numpy namespace is defined
+def __getattr__(name: str) -> Any: ...