@@ -54,7 +54,7 @@ def validator(
54
54
check_fields : bool = True ,
55
55
whole : bool = None ,
56
56
allow_reuse : bool = False ,
57
- ) -> Callable [[AnyCallable ], classmethod ]:
57
+ ) -> Callable [[AnyCallable ], classmethod ]: # type: ignore[type-arg]
58
58
"""
59
59
Decorate methods on the class indicating that they should be used to validate fields
60
60
:param fields: which field(s) the method should be called on
@@ -81,7 +81,7 @@ def validator(
81
81
assert each_item is False , '"each_item" and "whole" conflict, remove "whole"'
82
82
each_item = not whole
83
83
84
- def dec (f : AnyCallable ) -> classmethod :
84
+ def dec (f : AnyCallable ) -> classmethod : # type: ignore[type-arg]
85
85
f_cls = _prepare_validator (f , allow_reuse )
86
86
setattr (
87
87
f_cls ,
@@ -97,20 +97,20 @@ def dec(f: AnyCallable) -> classmethod:
97
97
98
98
99
99
@overload
100
- def root_validator (_func : AnyCallable ) -> classmethod :
100
+ def root_validator (_func : AnyCallable ) -> classmethod : # type: ignore[type-arg]
101
101
...
102
102
103
103
104
104
@overload
105
105
def root_validator (
106
106
* , pre : bool = False , allow_reuse : bool = False , skip_on_failure : bool = False
107
- ) -> Callable [[AnyCallable ], classmethod ]:
107
+ ) -> Callable [[AnyCallable ], classmethod ]: # type: ignore[type-arg]
108
108
...
109
109
110
110
111
111
def root_validator (
112
112
_func : Optional [AnyCallable ] = None , * , pre : bool = False , allow_reuse : bool = False , skip_on_failure : bool = False
113
- ) -> Union [classmethod , Callable [[AnyCallable ], classmethod ]]:
113
+ ) -> Union [classmethod , Callable [[AnyCallable ], classmethod ]]: # type: ignore[type-arg]
114
114
"""
115
115
Decorate methods on a model indicating that they should be used to validate (and perhaps modify) data either
116
116
before or after standard model parsing/validation is performed.
@@ -122,7 +122,7 @@ def root_validator(
122
122
)
123
123
return f_cls
124
124
125
- def dec (f : AnyCallable ) -> classmethod :
125
+ def dec (f : AnyCallable ) -> classmethod : # type: ignore[type-arg]
126
126
f_cls = _prepare_validator (f , allow_reuse )
127
127
setattr (
128
128
f_cls , ROOT_VALIDATOR_CONFIG_KEY , Validator (func = f_cls .__func__ , pre = pre , skip_on_failure = skip_on_failure )
@@ -132,7 +132,7 @@ def dec(f: AnyCallable) -> classmethod:
132
132
return dec
133
133
134
134
135
- def _prepare_validator (function : AnyCallable , allow_reuse : bool ) -> classmethod :
135
+ def _prepare_validator (function : AnyCallable , allow_reuse : bool ) -> classmethod : # type: ignore[type-arg]
136
136
"""
137
137
Avoid validators with duplicated names since without this, validators can be overwritten silently
138
138
which generally isn't the intended behaviour, don't run in ipython (see #312) or if allow_reuse is False.
@@ -325,7 +325,7 @@ def _generic_validator_basic(validator: AnyCallable, sig: 'Signature', args: Set
325
325
return lambda cls , v , values , field , config : validator (v , values = values , field = field , config = config )
326
326
327
327
328
- def gather_all_validators (type_ : 'ModelOrDc' ) -> Dict [str , classmethod ]:
328
+ def gather_all_validators (type_ : 'ModelOrDc' ) -> Dict [str , classmethod ]: # type: ignore[type-arg]
329
329
all_attributes = ChainMap (* [cls .__dict__ for cls in type_ .__mro__ ])
330
330
return {
331
331
k : v
0 commit comments