forked from quantumlib/Cirq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dataclass_json_dict (quantumlib#4391)
Dataclasses keep track of their relevant fields, so we can automatically generate these. Dataclasses are implemented with somewhat complex metaprogramming, and tooling (PyCharm, mypy) have special cases for dealing with classes decorated with `@dataclass`. There is very little support (and no plans for support) for decorators that wrap `@dataclass` (like `@cirq.json_serializable_dataclass`) or combining additional decorators with `@dataclass`. Although not as elegant, you may want to consider explicitly defining `_json_dict_` on your dataclasses which simply `return dataclass_json_dict(self)`.
- Loading branch information
1 parent
00bcc0c
commit a2e8fc0
Showing
5 changed files
with
50 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,7 @@ | |
to_json, | ||
read_json, | ||
obj_to_dict_helper, | ||
dataclass_json_dict, | ||
SerializableByKey, | ||
SupportsJSON, | ||
) | ||
|
This file contains 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
This file contains 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