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

🔧 Type annotate aiida/orm/utils/serialize.py #5832

Merged
merged 4 commits into from
Dec 13, 2022

Conversation

chrisjsewell
Copy link
Member

No description provided.

@chrisjsewell chrisjsewell changed the title 🔧 Type annotate aiida/orm/utils/serialize.py 🔧 Type annotate aiida/orm/utils/serialize.py Dec 13, 2022
deserialized = loader.construct_scalar(serialized)
def enum_constructor(loader: yaml.Loader, serialized: yaml.Node) -> Enum:
"""Construct an enum from the serialized representation."""
deserialized: str = loader.construct_scalar(serialized) # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the warnings here for the loader.construct_scalar? If they cannot be fixed, should we at least maybe add the more specific error code to ignore instead of a blanket ignore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added ignore if specific errors.
They are needed to because, essentially, the constructors have been written assuming that the objects have been serialized using the complimentary represent_ functions in this module.
To remove them, you would need to start adding in assert isinstance checks

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all good

@chrisjsewell chrisjsewell merged commit 6d0b7b8 into aiidateam:main Dec 13, 2022
@chrisjsewell chrisjsewell deleted the type-serialize branch December 13, 2022 13:39
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.

None yet

2 participants