-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
There's a bad deprecation warning in the JSON serialization:
def _json_dict_with_cirq_type(obj: Any):
base_dict = obj._json_dict_()
if 'cirq_type' in base_dict:
# TODO: upgrade to ValueError in v0.15
warnings.warn(
f"Found 'cirq_type': '{base_dict['cirq_type']}' in _json_dict_. "
f"Custom values of this field are not permitted, and will produce "
"an error starting in Cirq v0.15.",
DeprecationWarning,
)
return base_dict
return {'cirq_type': json_cirq_type(type(obj)), **base_dict}
This cannot be changed into an error. The main guarantee provided by json serialization is that it will continue to work forever. If using this key was going to be an error, it had to start as an error when json serialization was first written. You can't change it now, because that might break things which would mean they wouldn't continue to work forever.
I am aware of specific files out there that use these values, because stimcirq uses these keys for its custom operations. I've serialized circuits that had those operations in it. I expect them to continue to parse.
You are about to make a change that would break the main guarantee provided by json serialization. DO NOT DO THIS. Remove this deprecation warning instead of moving forward with it.