summaryrefslogtreecommitdiff
path: root/puzzles/tricky_typevar_constrained.py
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-02-20 12:55:32 +0100
committerMartin Fischer <martin@push-f.com>2022-02-23 15:59:32 +0100
commit0b6c028fd4be048bde9369b870e6fe4b80577886 (patch)
treef3948a5b35156e0e4c00f32cd577067eb31ce497 /puzzles/tricky_typevar_constrained.py
publish
Diffstat (limited to 'puzzles/tricky_typevar_constrained.py')
-rw-r--r--puzzles/tricky_typevar_constrained.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/puzzles/tricky_typevar_constrained.py b/puzzles/tricky_typevar_constrained.py
new file mode 100644
index 0000000..50ce10a
--- /dev/null
+++ b/puzzles/tricky_typevar_constrained.py
@@ -0,0 +1,9 @@
+from typing import TypeVar, Any, Union
+
+V = TypeVar("V", str, bytes)
+
+def check_v(x: Union[V, list[V]]) -> V:
+ raise NotImplementedError()
+
+def foo(a: list[Any]):
+ check_v(a)