Skip to content

Commit d79c4c3

Browse files
committed
Fixed SonarQube maintainability warnings
1 parent f22a1de commit d79c4c3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/coherence/serialization.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030

3131
MAGIC_BYTE: Final[bytes] = b"\x15"
3232

33-
_type_to_alias: Final[Dict[Type[Any], str]] = dict()
33+
_type_to_alias: Final[Dict[Type[Any], str]] = {}
3434
"""A mapping of proxied Python types to their alias."""
3535

36-
_alias_to_type: Final[Dict[str, Type[Any]]] = dict()
36+
_alias_to_type: Final[Dict[str, Type[Any]]] = {}
3737
"""A mapping of aliases to their proxied Python type."""
3838

39-
_attribute_mappings: Final[Dict[Type[Any], Dict[str, str]]] = dict()
39+
_attribute_mappings: Final[Dict[Type[Any], Dict[str, str]]] = {}
4040
"""A mapping of object attributes that require a different name when serialized/deserialized."""
4141

42-
_attribute_mappings_rev: Final[Dict[Type[Any], Dict[str, str]]] = dict()
42+
_attribute_mappings_rev: Final[Dict[Type[Any], Dict[str, str]]] = {}
4343
"""The same mapping as _attribute_mappings, but in reverse for deserialization."""
4444

4545

@@ -165,7 +165,7 @@ def _flatten_obj(self, obj: Any) -> dict[str, str | dict[str, list[dict[str, Any
165165
if alias is not None:
166166
marker = result.get(_JSON_PICKLE_OBJ, None)
167167
if marker is not None:
168-
actual: dict[str, Any] = dict()
168+
actual: dict[str, Any] = {}
169169
actual[_META_CLASS] = alias
170170
for key, value in result.items():
171171
# ignore jsonpickle specific content as well as protected keys
@@ -190,11 +190,11 @@ def _flatten_obj(self, obj: Any) -> dict[str, str | dict[str, list[dict[str, Any
190190
and _META_VERSION not in value_
191191
and _META_ENUM not in value_
192192
):
193-
entries = list()
193+
entries = []
194194
for key_inner, value_inner in value.items():
195195
entries.append({_JSON_KEY: key_inner, _JSON_VALUE: value_inner})
196196

197-
padding: dict[str, Any] = dict()
197+
padding: dict[str, Any] = {}
198198
padding["entries"] = entries
199199
value_ = padding
200200

@@ -230,7 +230,7 @@ def _restore(self, obj: Any) -> Any:
230230
metadata: Any = obj.get(_META_CLASS, None)
231231
if metadata is not None:
232232
type_: Optional[Type[Any]] = _type_for(metadata)
233-
actual: dict[Any, Any] = dict()
233+
actual: dict[Any, Any] = {}
234234
if type_ is None:
235235
if "map" in metadata.lower():
236236
for entry in obj[_JSON_ENTRIES]:
@@ -264,7 +264,7 @@ def _restore(self, obj: Any) -> Any:
264264
if len(obj) == 1:
265265
entries = obj.get(_JSON_ENTRIES, None)
266266
if entries is not None:
267-
actual = dict()
267+
actual = {}
268268
for entry in obj[_JSON_ENTRIES]:
269269
actual[entry[_JSON_KEY]] = entry[_JSON_VALUE]
270270
return super().restore(actual, reset=False)

0 commit comments

Comments
 (0)