Skip to content

Commit 78a8b97

Browse files
committed
serialize_tags: make .filter(tags__contains='string') work
the example in readme says this example works, but actually it splits the argument by ',' unconditionally, expecting a list. so a string will be made into a "s,t,r,i,n,g". so we should handle getting passed either a single string and pass it through unchanged, or a list and join them actually if a list, we'd want to dedupe so we use a set which is the native type of the library for tags anyways
1 parent 16d6e54 commit 78a8b97

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tasklib/serializing.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ def deserialize_annotations(self, data):
175175
return [TaskAnnotation(self, d) for d in data] if data else []
176176

177177
def serialize_tags(self, tags):
178-
return ','.join(tags) if tags else ''
178+
if isinstance(tags, list):
179+
tags = set(tags)
180+
if isinstance(tags, set):
181+
return ','.join(tags) if tags else ''
182+
if isinstance(tags, str):
183+
return tags
184+
raise ValueError("serialize_tags only supports list, set or string")
179185

180186
def deserialize_tags(self, tags):
181187
if isinstance(tags, str):

0 commit comments

Comments
 (0)