@@ -138,7 +138,6 @@ def __init__(self, schema, types=(), resolver=None):
138
138
139
139
self ._types = dict (self .DEFAULT_TYPES )
140
140
self ._types .update (types )
141
- self ._types ["any" ] = tuple (self ._types .values ())
142
141
143
142
if resolver is None :
144
143
resolver = RefResolver .from_schema (schema )
@@ -152,7 +151,9 @@ def is_type(self, instance, type):
152
151
153
152
"""
154
153
155
- if type not in self ._types :
154
+ if type == "any" :
155
+ return True
156
+ elif type not in self ._types :
156
157
raise UnknownType (type )
157
158
type = self ._types [type ]
158
159
@@ -232,11 +233,12 @@ def validate_type(self, types, instance, schema):
232
233
types = _list (types )
233
234
234
235
for type in types :
236
+ if type == "any" or (
237
+
235
238
# Ouch. Brain hurts. Two paths here, either we have a schema, then
236
239
# check if the instance is valid under it
237
- if ((
238
- self .is_type (type , "object" ) and
239
- self .is_valid (instance , type )
240
+
241
+ self .is_type (type , "object" ) and self .is_valid (instance , type )
240
242
241
243
# Or we have a type as a string, just check if the instance is that
242
244
# type. Also, HACK: we can reach the `or` here if skip_types is
@@ -245,7 +247,7 @@ def validate_type(self, types, instance, schema):
245
247
) or (
246
248
self .is_type (type , "string" ) and
247
249
(self .is_type (instance , type ) or type not in self ._types )
248
- )) :
250
+ ):
249
251
return
250
252
else :
251
253
yield ValidationError (_types_msg (instance , types ))
0 commit comments