summaryrefslogtreecommitdiff
path: root/numpy/typing
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-10-25 12:02:35 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-10-25 12:20:23 +0200
commitfe90af01d080b285edfcd2d9f62d055286ec72fb (patch)
tree5855a5bdb97711e55e2e5f004c6968b04fbf3d41 /numpy/typing
parent0f6feaa9c619251a0c62fb7baa49c369069340d9 (diff)
downloadnumpy-fe90af01d080b285edfcd2d9f62d055286ec72fb.tar.gz
TST: Update the typing tests
Diffstat (limited to 'numpy/typing')
-rw-r--r--numpy/typing/tests/data/fail/arithmetic.pyi11
-rw-r--r--numpy/typing/tests/data/fail/comparisons.pyi9
-rw-r--r--numpy/typing/tests/data/reveal/ndarray_misc.pyi5
-rw-r--r--numpy/typing/tests/data/reveal/ufunc_config.pyi6
-rw-r--r--numpy/typing/tests/data/reveal/version.pyi8
5 files changed, 26 insertions, 13 deletions
diff --git a/numpy/typing/tests/data/fail/arithmetic.pyi b/numpy/typing/tests/data/fail/arithmetic.pyi
index 02bbffa53..b99b24c1f 100644
--- a/numpy/typing/tests/data/fail/arithmetic.pyi
+++ b/numpy/typing/tests/data/fail/arithmetic.pyi
@@ -28,6 +28,7 @@ AR_LIKE_M: List[np.datetime64]
# NOTE: mypys `NoReturn` errors are, unfortunately, not that great
_1 = AR_b - AR_LIKE_b # E: Need type annotation
_2 = AR_LIKE_b - AR_b # E: Need type annotation
+AR_i - bytes() # E: No overload variant
AR_f - AR_LIKE_m # E: Unsupported operand types
AR_f - AR_LIKE_M # E: Unsupported operand types
@@ -91,11 +92,11 @@ AR_f *= AR_LIKE_m # E: incompatible type
# Array power
-AR_b **= AR_LIKE_b # E: incompatible type
-AR_b **= AR_LIKE_u # E: incompatible type
-AR_b **= AR_LIKE_i # E: incompatible type
-AR_b **= AR_LIKE_f # E: incompatible type
-AR_b **= AR_LIKE_c # E: incompatible type
+AR_b **= AR_LIKE_b # E: Invalid self argument
+AR_b **= AR_LIKE_u # E: Invalid self argument
+AR_b **= AR_LIKE_i # E: Invalid self argument
+AR_b **= AR_LIKE_f # E: Invalid self argument
+AR_b **= AR_LIKE_c # E: Invalid self argument
AR_u **= AR_LIKE_i # E: incompatible type
AR_u **= AR_LIKE_f # E: incompatible type
diff --git a/numpy/typing/tests/data/fail/comparisons.pyi b/numpy/typing/tests/data/fail/comparisons.pyi
index 0432177e2..febd0a18c 100644
--- a/numpy/typing/tests/data/fail/comparisons.pyi
+++ b/numpy/typing/tests/data/fail/comparisons.pyi
@@ -21,8 +21,7 @@ AR_M > AR_i # E: Unsupported operand types
AR_M > AR_f # E: Unsupported operand types
AR_M > AR_m # E: Unsupported operand types
-# Unfortunately `NoReturn` errors are not the most descriptive
-_1 = AR_i > str() # E: No overload variant
-_2 = AR_i > bytes() # E: Need type annotation
-_3 = str() > AR_M # E: Unsupported operand types
-_4 = bytes() > AR_M # E: Need type annotation
+AR_i > str() # E: No overload variant
+AR_i > bytes() # E: No overload variant
+str() > AR_M # E: Unsupported operand types
+bytes() > AR_M # E: Unsupported operand types
diff --git a/numpy/typing/tests/data/reveal/ndarray_misc.pyi b/numpy/typing/tests/data/reveal/ndarray_misc.pyi
index e384b5388..2d900c53d 100644
--- a/numpy/typing/tests/data/reveal/ndarray_misc.pyi
+++ b/numpy/typing/tests/data/reveal/ndarray_misc.pyi
@@ -204,3 +204,8 @@ reveal_type(AR_V[0, ...]) # E: numpy.ndarray[Any, numpy.dtype[numpy.void]]
reveal_type(AR_V[:]) # E: numpy.ndarray[Any, numpy.dtype[numpy.void]]
reveal_type(AR_V["a"]) # E: numpy.ndarray[Any, numpy.dtype[Any]]
reveal_type(AR_V[["a", "b"]]) # E: numpy.ndarray[Any, numpy.dtype[numpy.void]]
+
+reveal_type(AR_f8.dump("test_file")) # E: None
+reveal_type(AR_f8.dump(b"test_file")) # E: None
+with open("test_file", "wb") as f:
+ reveal_type(AR_f8.dump(f)) # E: None
diff --git a/numpy/typing/tests/data/reveal/ufunc_config.pyi b/numpy/typing/tests/data/reveal/ufunc_config.pyi
index 26be80314..6848a3cb5 100644
--- a/numpy/typing/tests/data/reveal/ufunc_config.pyi
+++ b/numpy/typing/tests/data/reveal/ufunc_config.pyi
@@ -17,9 +17,9 @@ reveal_type(np.geterr()) # E: TypedDict('numpy.core._ufunc_config._ErrDict'
reveal_type(np.setbufsize(4096)) # E: int
reveal_type(np.getbufsize()) # E: int
-reveal_type(np.seterrcall(func)) # E: Union[None, def (builtins.str, builtins.int) -> Any, numpy.core._ufunc_config._SupportsWrite]
-reveal_type(np.seterrcall(Write())) # E: Union[None, def (builtins.str, builtins.int) -> Any, numpy.core._ufunc_config._SupportsWrite]
-reveal_type(np.geterrcall()) # E: Union[None, def (builtins.str, builtins.int) -> Any, numpy.core._ufunc_config._SupportsWrite]
+reveal_type(np.seterrcall(func)) # E: Union[None, def (builtins.str, builtins.int) -> Any, numpy._SupportsWrite[builtins.str]]
+reveal_type(np.seterrcall(Write())) # E: Union[None, def (builtins.str, builtins.int) -> Any, numpy._SupportsWrite[builtins.str]]
+reveal_type(np.geterrcall()) # E: Union[None, def (builtins.str, builtins.int) -> Any, numpy._SupportsWrite[builtins.str]]
reveal_type(np.errstate(call=func, all="call")) # E: numpy.errstate[def (a: builtins.str, b: builtins.int)]
reveal_type(np.errstate(call=Write(), divide="log", over="log")) # E: numpy.errstate[ufunc_config.Write]
diff --git a/numpy/typing/tests/data/reveal/version.pyi b/numpy/typing/tests/data/reveal/version.pyi
new file mode 100644
index 000000000..e53837647
--- /dev/null
+++ b/numpy/typing/tests/data/reveal/version.pyi
@@ -0,0 +1,8 @@
+import numpy.version
+
+reveal_type(numpy.version.version) # E: str
+reveal_type(numpy.version.__version__) # E: str
+reveal_type(numpy.version.full_version) # E: str
+reveal_type(numpy.version.git_revision) # E: str
+reveal_type(numpy.version.release) # E: bool
+reveal_type(numpy.version.short_version) # E: str