Skip to content

Commit c37e7b3

Browse files
author
Joel Collins
committed
Added type checking to tag_spec
1 parent 9a0f178 commit c37e7b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

labthings/server/spec/utilities.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ def tag_spec(obj, tags, add_group: bool = True):
2828
obj.__apispec__["tags"] = set()
2929

3030
if isinstance(tags, set) or isinstance(tags, list):
31+
if not all([isinstance(e, str) for e in tags]):
32+
raise TypeError("All tags must be strings")
3133
obj.__apispec__["tags"] = obj.__apispec__["tags"].union(tags)
32-
else:
34+
elif isinstance(tags, str):
3335
obj.__apispec__["tags"].add(tags)
36+
else:
37+
raise TypeError("All tags must be strings")
3438

3539

3640
def get_spec(obj):

0 commit comments

Comments
 (0)