Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions test/collection/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
[
(1, [int], False),
(1.0, [int], True),
(True, [int], True),
([1, 1], [List], False),
(np.array([1, 2, 3]), [_ExtraTypes.NUMPY], False),
(np.array([1, 2, 3]), [_ExtraTypes.NUMPY, List], False),
Expand Down
4 changes: 4 additions & 0 deletions weaviate/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ def _is_valid(expected: Any, value: Any) -> bool:
return any(isinstance(val, union_arg) for val in value for union_arg in union_args)
else:
return all(isinstance(val, args[0]) for val in value)
# bool is a subclass of int, so isinstance(True, int) is True. Reject a
# bool where a plain int is expected so it is not silently coerced to 0/1.
if expected is int and isinstance(value, bool):
return False
return isinstance(value, expected)