type type type type type type type

This commit is contained in:
Julian Berman
2013-02-03 00:44:54 -05:00
parent e0836bb07b
commit a7c95aa885

View File

@@ -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)