From e1c2fa8d4f248cb8529dd671214481a4f78fcc43 Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Thu, 30 Nov 2023 15:13:33 -0800 Subject: [PATCH] syntax --- src/totypes/json_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/totypes/json_utils.py b/src/totypes/json_utils.py index 49fac31..bb698ad 100644 --- a/src/totypes/json_utils.py +++ b/src/totypes/json_utils.py @@ -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: