From 47faa6902d2f9b266fa354d35f7eb7eb4db25097 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 30 May 2025 10:59:11 +0100 Subject: [PATCH 1/2] prioritise dict method when serialising --- autoconf/dictable.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autoconf/dictable.py b/autoconf/dictable.py index 225e953..50b7ed6 100644 --- a/autoconf/dictable.py +++ b/autoconf/dictable.py @@ -64,6 +64,12 @@ def compound_key_dict(obj): def to_dict(obj, filter_args: Tuple[str, ...] = ()) -> dict: + if hasattr(obj, "dict"): + try: + return obj.dict() + except TypeError as e: + logger.debug(e) + if isinstance(obj, (int, float, str, bool, type(None))): return obj @@ -88,12 +94,6 @@ def to_dict(obj, filter_args: Tuple[str, ...] = ()) -> dict: "class_path": obj.__module__ + "." + obj.__qualname__, } - if hasattr(obj, "dict"): - try: - return obj.dict() - except TypeError as e: - logger.debug(e) - if is_array(obj): try: return nd_array_as_dict(obj) From 2eb44458a7457e966d400e4fbba5d8d5ac898314 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 30 May 2025 10:59:11 +0100 Subject: [PATCH 2/2] prioritise dict method when serialising --- autoconf/dictable.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/autoconf/dictable.py b/autoconf/dictable.py index 225e953..50b7ed6 100644 --- a/autoconf/dictable.py +++ b/autoconf/dictable.py @@ -64,6 +64,12 @@ def compound_key_dict(obj): def to_dict(obj, filter_args: Tuple[str, ...] = ()) -> dict: + if hasattr(obj, "dict"): + try: + return obj.dict() + except TypeError as e: + logger.debug(e) + if isinstance(obj, (int, float, str, bool, type(None))): return obj @@ -88,12 +94,6 @@ def to_dict(obj, filter_args: Tuple[str, ...] = ()) -> dict: "class_path": obj.__module__ + "." + obj.__qualname__, } - if hasattr(obj, "dict"): - try: - return obj.dict() - except TypeError as e: - logger.debug(e) - if is_array(obj): try: return nd_array_as_dict(obj)