Skip to content

closes #261: change label type to str#262

Merged
dave-doty merged 2 commits intodevfrom
261-change-label-type-to-string
Jul 18, 2023
Merged

closes #261: change label type to str#262
dave-doty merged 2 commits intodevfrom
261-change-label-type-to-string

Conversation

@dave-doty
Copy link
Copy Markdown
Member

Description

Changed the type of label field in Strand, Domain, Loopout, and Extension to str instead of an arbitrary object.

Related Issue

#261

Motivation and Context

Supporting arbitrary data is more complex, both for the type checking (requiring some ugly Generic declarations), and for trying to serialize and deserialize automatically. Instead users can serialize and deserialize manually using the json package:

import json

nums = [1, 2, 3]
strand.label = json.dumps(nums)  # stores strand.label as the string '[1, 2, 3]'

# and to get the structured data back out:
nums = json.loads(strand.label)  # nums is now the list [1, 2, 3]

How Has This Been Tested?

Mostly just changed type hints, so checked that there are no mypy errors.

Screenshots (if appropriate):

@dave-doty dave-doty merged commit f198708 into dev Jul 18, 2023
@dave-doty dave-doty deleted the 261-change-label-type-to-string branch July 18, 2023 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant