[SYNPY-1708] None values don't become annotations#1417
Open
andrewelamb wants to merge 8 commits into
Open
Conversation
BryanFauble
reviewed
Jun 26, 2026
thomasyu888
reviewed
Jun 26, 2026
thomasyu888
reviewed
Jun 26, 2026
thomasyu888
reviewed
Jun 26, 2026
BryanFauble
approved these changes
Jun 26, 2026
linglp
approved these changes
Jun 26, 2026
linglp
left a comment
Contributor
There was a problem hiding this comment.
Hi @andrewelamb ! I could approve too. I found some edge cases of null values that we could consider to cover, but I am also fine with how you have written here. There's also a small piece of dead code that can be removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
Setting an annotation key to
None(or to a value that contains no real data) did not behave intuitively when storing an entity:Nonewas stored as the literal string"None"rather than being treated as "no value".Nonevalues (e.g.[None, None]) was stored as["None", "None"].Nonewith real values (e.g.[None, "value"]) was stored as["None", "value"], polluting the data with a bogus"None"element.Solution:
_convert_to_annotations_listnow treatsNoneas the absence of a value:Noneis skipped entirely (the key is omitted), rather than being stringified.Noneelements are stripped from list values before type inference, so a mixed list like[None, "value"]is stored as["value"].None(includingNone,[], and[None, None]) is omitted.Type inference now runs on the
None-stripped element list, so the inferred Synapse type (STRING/BOOLEAN/LONG/DOUBLE/TIMESTAMP_MS) is no longer skewed byNoneplaceholders. The literal string"None"is unaffected and is still stored as a normal string value.The function also gained a full docstring documenting the conversion behavior, including the heterogeneous-list fallback to STRING.
Testing:
test_setting_annotation_key_to_noneintests/integration/synapseclient/models/async/test_file_async.pythat stores a file with one annotation set to a primitiveNone, one to a list ofNonevalues, one to an empty list, one to a list mixingNonewith a real value, and one to the literal string"None", then retrieves a fresh copy and asserts:None, list-of-None, and empty-list keys are not stored at all.[None, "None"]round-trips as["None"](theNonestripped)."None"is stored as a normal string value.tests/unit/synapseclient/unit_test_annotations.pycovering_convert_to_annotations_listdirectly:test__convert_to_annotations_list__none_values— asserts a primitiveNone, a list of onlyNone([None, None]), and an empty list are all omitted; a mixed list ([None, "value", None]) has itsNones stripped to["value"]; and the literal string"None"is kept as a normal STRING value.test__convert_to_annotations_list__mixed_list_preserves_type— asserts that strippingNonefrom typed lists still infers the correct Synapse type (LONG, DOUBLE, BOOLEAN) rather than falling back to STRING.