Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion configurize/allowed_types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from dataclasses import is_dataclass

from loguru import logger

SEQUENCE_TYPES = (
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions configurize/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"}
Expand Down