Skip to content

Commit

Permalink
Merge pull request NeuralEnsemble#1399 from zm711/check-key
Browse files Browse the repository at this point in the history
Check that keys of nested dictionaries in annotations are `str`
  • Loading branch information
apdavison authored Feb 22, 2024
2 parents 0c175b4 + e2fd822 commit 620a2a8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion neo/core/baseneo.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def _check_annotations(value):
if not issubclass(value.dtype.type, ALLOWED_ANNOTATION_TYPES):
raise ValueError(f"Invalid annotation. NumPy arrays with dtype {value.dtype.type}" f"are not allowed")
elif isinstance(value, dict):
for element in value.values():
for key, element in value.items():
if not isinstance(key, str):
raise TypeError(f"Annotations keys must be strings not of type {type(key)}")
_check_annotations(element)
elif isinstance(value, (list, tuple)):
for element in value:
Expand Down

0 comments on commit 620a2a8

Please sign in to comment.