Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up ReferencedObject typing #324

Open
jakebeal opened this issue Oct 5, 2021 · 2 comments
Open

Clean up ReferencedObject typing #324

jakebeal opened this issue Oct 5, 2021 · 2 comments
Milestone

Comments

@jakebeal
Copy link
Contributor

jakebeal commented Oct 5, 2021

We are inconsistent about the type declarations regarding ReferencedObject properties.
For example, Constraint uses type Union[Identified,str]:

def __init__(self, restriction: str, subject: Union[Identified, str],
object: Union[Identified, str], *, name: str = None,

while Interface uses types List[str] rather than List[Union[Identified,str]] (or would it be better as Union[List[Identified],List[str])? https://github.com/SynBioDex/pySBOL3/blob/57875793642ca25ad5d5307b85051d8be80e5801/sbol3/interface.py#L13-L14

Since we do in fact allow union types, we should propagate that typing information appropriately.

@tcmitchell
Copy link
Collaborator

We could define an ObjectReference to be equivalent to Union[Identified, str] and then use that for the type declaration of variables throughout. Where a referenced object is desired we could then say foo: ObjectReference or bar: List[ObjectReference].

@jakebeal
Copy link
Contributor Author

This would lose some of the typing information that we currently have, such as in the constructor for Location:

def __init__(self, sequence: Union[Sequence, str],

Is there a way to parameterize this to ObjectReference[Sequence], which would allow the best of both?

@jakebeal jakebeal modified the milestones: beta, 1.0 Feb 8, 2022
@tcmitchell tcmitchell modified the milestones: 1.0, 1.1 Feb 10, 2022
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

No branches or pull requests

2 participants