Skip to content

Commit 620a2a8

Browse files
authored
Merge pull request #1399 from zm711/check-key
Check that keys of nested dictionaries in annotations are `str`
2 parents 0c175b4 + e2fd822 commit 620a2a8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

neo/core/baseneo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def _check_annotations(value):
4545
if not issubclass(value.dtype.type, ALLOWED_ANNOTATION_TYPES):
4646
raise ValueError(f"Invalid annotation. NumPy arrays with dtype {value.dtype.type}" f"are not allowed")
4747
elif isinstance(value, dict):
48-
for element in value.values():
48+
for key, element in value.items():
49+
if not isinstance(key, str):
50+
raise TypeError(f"Annotations keys must be strings not of type {type(key)}")
4951
_check_annotations(element)
5052
elif isinstance(value, (list, tuple)):
5153
for element in value:

0 commit comments

Comments
 (0)