File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed
typesafety/test_typeclass/test_generics Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ - case : typeclass_concrete_generic
2
+ disable_cache : false
3
+ main : |
4
+ from typing import List
5
+ from classes import typeclass
6
+
7
+ class SomeDelegate(object):
8
+ ...
9
+
10
+ @typeclass
11
+ def some(instance) -> int:
12
+ ...
13
+
14
+ @some.instance(List[int], delegate=SomeDelegate)
15
+ def _some_list_int(instance: List[int]) -> int:
16
+ ...
17
+
18
+ some([1, 2, 3])
19
+ some([])
20
+ some(['a']) # E: List item 0 has incompatible type "str"; expected "int"
21
+
22
+
23
+ - case : typeclass_concrete_generic_delegate_and_protocol
24
+ disable_cache : false
25
+ main : |
26
+ from typing import List
27
+ from classes import typeclass
28
+
29
+ class SomeDelegate(object):
30
+ ...
31
+
32
+ @typeclass
33
+ def some(instance) -> int:
34
+ ...
35
+
36
+ @some.instance(List[int], delegate=SomeDelegate, is_protocol=True)
37
+ def _some_list_int(instance: List[int]) -> int:
38
+ ...
39
+ out : |
40
+ main:11: error: Both "is_protocol" and "delegate" arguments passed, they are exclusive
41
+ main:11: error: Regular types must be passed with "is_protocol=False"
42
+
43
+
44
+ - case : typeclass_delegate_with_regular_type
45
+ disable_cache : false
46
+ main : |
47
+ from classes import typeclass
48
+
49
+ class SomeDelegate(object):
50
+ ...
51
+
52
+ @typeclass
53
+ def some(instance) -> int:
54
+ ...
55
+
56
+ @some.instance(int, delegate=SomeDelegate)
57
+ def _some_int(instance: int) -> int:
58
+ ...
59
+
60
+ some(1)
You can’t perform that action at this time.
0 commit comments