Change dataclasses.dataclass to pydantic.dataclasses.dataclass#105
Open
deanpoulos wants to merge 2 commits into
Open
Change dataclasses.dataclass to pydantic.dataclasses.dataclass#105deanpoulos wants to merge 2 commits into
deanpoulos wants to merge 2 commits into
Conversation
Contributor
|
If it doesn't break anything, this is probably a pretty major improvement for QUAM, great idea! |
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.
This change is motivated by the following use-case.
Let's say I create a
QuAMobject to represent my QPU. Since every QuAM component is also a@quam_dataclass, I can use Pydantic's dataclass scheme generation feature as follows:Do this to generate a schema:
Then, if you load the schema into my IDE using a JSON schema mapping, you get required-field checking, type-checking, attribute hints, etc.
trimmed_output.webm
I believe we can enhance the number of schema features we exploit by doing something like this:
but I haven't tested it.
Could you please run this against tests and consider whether it will break fundamental features of QuAM? If not, I believe it would be a great improvement.