diff --git a/neo/core/baseneo.py b/neo/core/baseneo.py index 3bd49e5ca..cc031b03e 100644 --- a/neo/core/baseneo.py +++ b/neo/core/baseneo.py @@ -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: