summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-01-12 15:04:39 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2021-09-19 23:15:11 +0200
commit0ae66c201f5cbd1cd391701f1eeb1c78d92f4e1e (patch)
treeb567ef79cbd9cff347b2175e03fca50150feea4e /numpy
parenta315d5ee5ab56f434fdf196c3a9fe1dd7e72e5bd (diff)
downloadnumpy-0ae66c201f5cbd1cd391701f1eeb1c78d92f4e1e.tar.gz
TST: Added tests for `NestedSequence`
Diffstat (limited to 'numpy')
-rw-r--r--numpy/typing/tests/data/fail/nested_sequence.py17
-rw-r--r--numpy/typing/tests/data/reveal/nested_sequence.py23
2 files changed, 40 insertions, 0 deletions
diff --git a/numpy/typing/tests/data/fail/nested_sequence.py b/numpy/typing/tests/data/fail/nested_sequence.py
new file mode 100644
index 000000000..e28661a05
--- /dev/null
+++ b/numpy/typing/tests/data/fail/nested_sequence.py
@@ -0,0 +1,17 @@
+from typing import Sequence, Tuple, List
+import numpy.typing as npt
+
+a: Sequence[float]
+b: List[complex]
+c: Tuple[str, ...]
+d: int
+e: str
+
+def func(a: npt._NestedSequence[int]) -> None:
+ ...
+
+reveal_type(func(a)) # E: incompatible type
+reveal_type(func(b)) # E: incompatible type
+reveal_type(func(c)) # E: incompatible type
+reveal_type(func(d)) # E: incompatible type
+reveal_type(func(e)) # E: incompatible type
diff --git a/numpy/typing/tests/data/reveal/nested_sequence.py b/numpy/typing/tests/data/reveal/nested_sequence.py
new file mode 100644
index 000000000..07e24e357
--- /dev/null
+++ b/numpy/typing/tests/data/reveal/nested_sequence.py
@@ -0,0 +1,23 @@
+from typing import Sequence, Tuple, List, Any
+import numpy.typing as npt
+
+a: Sequence[int]
+b: Sequence[Sequence[int]]
+c: Sequence[Sequence[Sequence[int]]]
+d: Sequence[Sequence[Sequence[Sequence[int]]]]
+e: Sequence[bool]
+f: Tuple[int, ...]
+g: List[int]
+h: Sequence[Any]
+
+def func(a: npt._NestedSequence[int]) -> None:
+ ...
+
+reveal_type(func(a)) # E: None
+reveal_type(func(b)) # E: None
+reveal_type(func(c)) # E: None
+reveal_type(func(d)) # E: None
+reveal_type(func(e)) # E: None
+reveal_type(func(f)) # E: None
+reveal_type(func(g)) # E: None
+reveal_type(func(h)) # E: None