Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ def _value_equality_values_(self):
return self._init_probs, self._arc_probs

def _json_dict_(self) -> Dict[str, Any]:
return {
'cirq_type': self.__class__.__name__,
'init_probs': self._init_probs,
'arc_probs': self._arc_probs,
}
return {'init_probs': self._init_probs, 'arc_probs': self._arc_probs}

@classmethod
def _from_json_dict_(
Expand Down
8 changes: 2 additions & 6 deletions cirq-core/cirq/protocols/json_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import json
import numbers
import pathlib
import warnings
from typing import (
Any,
Callable,
Expand Down Expand Up @@ -188,8 +187,7 @@ def dataclass_json_dict(obj: Any) -> Dict[str, Any]:
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(
raise ValueError(
f"Found 'cirq_type': '{base_dict['cirq_type']}' in user-specified _json_dict_. "
"'cirq_type' is now automatically generated from the class's name and its "
"_json_namespace_ method as `cirq_type: '[<namespace>.]<class_name>'`."
Expand All @@ -201,10 +199,8 @@ def _json_dict_with_cirq_type(obj: Any):
"For backwards compatibility, third-party classes whose old 'cirq_type' value "
"does not match the new value must appear under BOTH values in the resolver "
"for that package. For details on defining custom resolvers, see the "
"DEFAULT_RESOLVER docstring in cirq-core/cirq/protocols/json_serialization.py.",
DeprecationWarning,
"DEFAULT_RESOLVER docstring in cirq-core/cirq/protocols/json_serialization.py."
)
return base_dict
return {'cirq_type': json_cirq_type(type(obj)), **base_dict}


Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/json_serialization_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def custom_resolver(name):
return HasOldJsonDict

test_resolvers = [custom_resolver] + cirq.DEFAULT_RESOLVERS
with cirq.testing.assert_deprecated("Found 'cirq_type'", deadline='v0.15'):
with pytest.raises(ValueError, match="Found 'cirq_type'"):
assert_json_roundtrip_works(HasOldJsonDict(), resolvers=test_resolvers)


Expand Down