From 245a9f4afeca3d2fcf44ec7d64dcf2260e154eb9 Mon Sep 17 00:00:00 2001 From: zhouhy Date: Mon, 19 Jan 2026 17:29:19 +0800 Subject: [PATCH 1/2] chores: clean err log --- configurize/config.py | 8 ++++++-- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configurize/config.py b/configurize/config.py index e9876b1..7ded207 100644 --- a/configurize/config.py +++ b/configurize/config.py @@ -357,8 +357,12 @@ def _get(self, name, deref=True): raise e def __getattribute__(self, name: str): - if not name.startswith("_"): - return self._get(name) + try: + if not name.startswith("_"): + return self._get(name) + except AttributeError as e: + e.__traceback__ = filter_traceback_frames("configurize", e.__traceback__) + raise e from None return super().__getattribute__(name) def __repr__(self): diff --git a/pyproject.toml b/pyproject.toml index f31ab82..7757ac4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "configurize" -version = "0.1.5" +version = "0.1.6" description = "Hierarchical configuration management with inheritance, cross-references, and diffing" readme = "README.md" license = {text = "MIT"} From bdde58c5a16e55a266146c2c8c87269bf6b4d8d9 Mon Sep 17 00:00:00 2001 From: zhouhy Date: Mon, 19 Jan 2026 17:29:41 +0800 Subject: [PATCH 2/2] feat: allow dataclasses, treat as dict --- configurize/allowed_types.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configurize/allowed_types.py b/configurize/allowed_types.py index 89bcaf4..381a776 100644 --- a/configurize/allowed_types.py +++ b/configurize/allowed_types.py @@ -1,3 +1,5 @@ +from dataclasses import is_dataclass + from loguru import logger SEQUENCE_TYPES = ( @@ -52,11 +54,15 @@ def recur_to_allowed_types(obj, extra_allowed=()): Any: the converted object """ - if not isinstance(obj, ALLOWED_TYPES + extra_allowed): + if not isinstance(obj, ALLOWED_TYPES + extra_allowed) and not is_dataclass(obj): logger.error(f"{obj} is NOT allowed in Config!!") obj = repr(obj) else: cls = type(obj) + if is_dataclass(obj): + cls = dict + obj = obj.__dict__ + if cls in SEQUENCE_TYPES: obj = cls([recur_to_allowed_types(i, extra_allowed) for i in obj]) elif cls in MAPPING_TYPES: