summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
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