Skip to content

Commit 3744981

Browse files
Remove deprecations in _json_dict_with_cirq_type. (#5630)
1 parent abdb5b6 commit 3744981

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

cirq-core/cirq/contrib/bayesian_network/bayesian_network_gate.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,7 @@ def _value_equality_values_(self):
180180
return self._init_probs, self._arc_probs
181181

182182
def _json_dict_(self) -> Dict[str, Any]:
183-
return {
184-
'cirq_type': self.__class__.__name__,
185-
'init_probs': self._init_probs,
186-
'arc_probs': self._arc_probs,
187-
}
183+
return {'init_probs': self._init_probs, 'arc_probs': self._arc_probs}
188184

189185
@classmethod
190186
def _from_json_dict_(

cirq-core/cirq/protocols/json_serialization.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import json
1818
import numbers
1919
import pathlib
20-
import warnings
2120
from typing import (
2221
Any,
2322
Callable,
@@ -188,8 +187,7 @@ def dataclass_json_dict(obj: Any) -> Dict[str, Any]:
188187
def _json_dict_with_cirq_type(obj: Any):
189188
base_dict = obj._json_dict_()
190189
if 'cirq_type' in base_dict:
191-
# TODO: upgrade to ValueError in v0.15
192-
warnings.warn(
190+
raise ValueError(
193191
f"Found 'cirq_type': '{base_dict['cirq_type']}' in user-specified _json_dict_. "
194192
"'cirq_type' is now automatically generated from the class's name and its "
195193
"_json_namespace_ method as `cirq_type: '[<namespace>.]<class_name>'`."
@@ -201,10 +199,8 @@ def _json_dict_with_cirq_type(obj: Any):
201199
"For backwards compatibility, third-party classes whose old 'cirq_type' value "
202200
"does not match the new value must appear under BOTH values in the resolver "
203201
"for that package. For details on defining custom resolvers, see the "
204-
"DEFAULT_RESOLVER docstring in cirq-core/cirq/protocols/json_serialization.py.",
205-
DeprecationWarning,
202+
"DEFAULT_RESOLVER docstring in cirq-core/cirq/protocols/json_serialization.py."
206203
)
207-
return base_dict
208204
return {'cirq_type': json_cirq_type(type(obj)), **base_dict}
209205

210206

cirq-core/cirq/protocols/json_serialization_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def custom_resolver(name):
9999
return HasOldJsonDict
100100

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

105105

0 commit comments

Comments
 (0)