type type type type type type type
This commit is contained in:
@@ -147,15 +147,15 @@ class Draft3Validator(object):
|
|||||||
return True
|
return True
|
||||||
elif type not in self._types:
|
elif type not in self._types:
|
||||||
raise UnknownType(type)
|
raise UnknownType(type)
|
||||||
type = self._types[type]
|
pytypes = self._types[type]
|
||||||
|
|
||||||
# bool inherits from int, so ensure bools aren't reported as integers
|
# bool inherits from int, so ensure bools aren't reported as integers
|
||||||
if isinstance(instance, bool):
|
if isinstance(instance, bool):
|
||||||
type = _flatten(type)
|
pytypes = _flatten(pytypes)
|
||||||
have_number = any(issubclass(t, numbers.Number) for t in type)
|
num = any(issubclass(pytype, numbers.Number) for pytype in pytypes)
|
||||||
if have_number and bool not in type:
|
if num and bool not in pytypes:
|
||||||
return False
|
return False
|
||||||
return isinstance(instance, type)
|
return isinstance(instance, pytypes)
|
||||||
|
|
||||||
def is_valid(self, instance, _schema=None):
|
def is_valid(self, instance, _schema=None):
|
||||||
error = next(self.iter_errors(instance, _schema), None)
|
error = next(self.iter_errors(instance, _schema), None)
|
||||||
|
|||||||
Reference in New Issue
Block a user