Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mfschubert committed Nov 30, 2023
1 parent 0de6c69 commit 6ad1084
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/totypes/json_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ def _convert_array(arr: Union[onp.ndarray, jnp.ndarray]) -> Tuple[str, Dict[str,
def _asdict(x: Any) -> Dict[str, Any]:
"""Converts dataclasses or namedtuples to dictionaries."""
if dataclasses.is_dataclass(x):
return {
field.name: getattr(x, field.name) for field in dataclasses.fields(x)
}
return {field.name: getattr(x, field.name) for field in dataclasses.fields(x)}
try:
return x._asdict() # type: ignore[no-any-return]
except AttributeError as exc:
Expand Down

0 comments on commit 6ad1084

Please sign in to comment.