Skip to content

Commit

Permalink
syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mfschubert committed Nov 30, 2023
1 parent 5329b54 commit e1c2fa8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/totypes/json_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ 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 dict(
[(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 e1c2fa8

Please sign in to comment.