-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Enforce [namespace.]classname format for cirq_type #4698
Labels
kind/design-issue
A conversation around design
Comments
CC @mpharrigan |
A change that could get us most of the way there is modifying the behavior of |
CirqBot
pushed a commit
that referenced
this issue
Nov 24, 2021
Fixes #4698. This enforces the `'cirq_type': [<namespace>.]<classname>` convention for JSON serialization by assigning the "cirq_type" field in our protocols instead of in each class. Any external users who define a "cirq_type" will see a warning about this; after a deprecation cycle, we will begin raising errors to prevent explicit definition of "cirq_type" in classes.
rht
pushed a commit
to rht/Cirq
that referenced
this issue
May 1, 2023
Fixes quantumlib#4698. This enforces the `'cirq_type': [<namespace>.]<classname>` convention for JSON serialization by assigning the "cirq_type" field in our protocols instead of in each class. Any external users who define a "cirq_type" will see a warning about this; after a deprecation cycle, we will begin raising errors to prevent explicit definition of "cirq_type" in classes.
harry-phasecraft
pushed a commit
to PhaseCraft/Cirq
that referenced
this issue
Oct 31, 2024
Fixes quantumlib#4698. This enforces the `'cirq_type': [<namespace>.]<classname>` convention for JSON serialization by assigning the "cirq_type" field in our protocols instead of in each class. Any external users who define a "cirq_type" will see a warning about this; after a deprecation cycle, we will begin raising errors to prevent explicit definition of "cirq_type" in classes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The type-serialization behavior added in #4693 made an implicit assumption that Cirq objects use
object.__class__.__name__
for the "cirq_type" field of their JSON representation, optionally prepended with a namespace. This is consistent with existing Cirq types, but until that PR it was merely a convention; now that code depends on it, we ought to enforce it.More specifically, this issue recommends moving assignment of the
cirq_type
JSON field from the_json_dict_
magic method of serializable classes into thecirq.to_json
protocol. As discussed in the linked issue, this will provide consistent behavior and reduce code redundancy.The text was updated successfully, but these errors were encountered: