You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/v/test_typing_validators.yml
+54-1Lines changed: 54 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -88,4 +88,57 @@
88
88
c = Converter()
89
89
90
90
v.customize(c, A, v.V(fields(A).a).ensure(v.greater_than(5))) # E: Argument 1 to "ensure" of "V" has incompatible type "Callable[[int], None]"; expected "Callable[[int | None], bool | None] | Callable[[bool], Callable[[int | None], None]]" [arg-type]
91
-
v.customize(c, A, v.V(fields(A).a).ensure(v.ignoring_none(v.len_between(0, 5)))) # E: Argument 1 to "ignoring_none" has incompatible type "Callable[[Sized], None]"; expected "Callable[[int], None]" [arg-type]
91
+
v.customize(c, A, v.V(fields(A).a).ensure(v.ignoring_none(v.len_between(0, 5)))) # E: Argument 1 to "ignoring_none" has incompatible type "Callable[[Sized], None]"; expected "Callable[[int], None]" [arg-type]
92
+
93
+
- case: for_all
94
+
main: |
95
+
from attrs import define, fields
96
+
from cattrs import v, Converter
97
+
98
+
@define
99
+
class A:
100
+
a: list[int]
101
+
102
+
c = Converter()
103
+
104
+
v.customize(c, A, v.V(fields(A).a).ensure(v.for_all(v.greater_than(5))))
105
+
106
+
- case: for_all_dict
107
+
main: |
108
+
from attrs import define, fields
109
+
from cattrs import v, Converter
110
+
111
+
@define
112
+
class A:
113
+
a: dict[str, int]
114
+
115
+
c = Converter()
116
+
117
+
v.customize(c, A, v.V(fields(A).a).ensure(v.for_all(v.len_between(0, 5))))
118
+
119
+
- case: for_all_error
120
+
main: |
121
+
from attrs import define, fields
122
+
from cattrs import v, Converter
123
+
from cattrs.v import for_all as fa
124
+
125
+
@define
126
+
class A:
127
+
a: list[int]
128
+
129
+
c = Converter()
130
+
131
+
v.customize(c, A, v.V(fields(A).a).ensure(fa(fa(v.greater_than(5))))) # E: Argument 1 to "for_all" has incompatible type "Callable[[bool], Callable[[Iterable[int]], None]]"; expected "Callable[[int], bool | None]" [arg-type]
132
+
133
+
- case: for_all_dict_error
134
+
main: |
135
+
from attrs import define, fields
136
+
from cattrs import v, Converter
137
+
138
+
@define
139
+
class A:
140
+
a: dict[str, int]
141
+
142
+
c = Converter()
143
+
144
+
v.customize(c, A, v.V(fields(A).a).ensure(v.for_all(v.greater_than(5)))) # E: Argument 1 to "greater_than" has incompatible type "int"; expected "str" [arg-type]
0 commit comments