Skip to content

Commit 417031d

Browse files
committed
fix(libs): dot_dict custom implementation of __getattr__ lead to issue accessing build-in attribute
When running pytest --doctest-modules, it try to inspect if things are wrapper by accessing the '__wrapped__' attribute. Our custom implementation lead to KeyError in certain situation. Try the custom logic first, and fallback to super().__getattribute__ to prevent the issue and ensure more robust handling.
1 parent 46cef8f commit 417031d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/mastermind/libs/utils/dot_dict.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ def convert(value: VT) -> Union[DotDict, VT]:
3939
self[key] = convert(value)
4040

4141
def __getattr__(self, key: str) -> Any:
42-
return self.__getitem__(key)
42+
try:
43+
return self.__getitem__(key)
44+
45+
except KeyError: # in case trying to access a built-in attribute
46+
return super().__getattribute__(key)
4347

4448
def __setattr__(self, key: str, value: Any) -> None:
4549
self.__setitem__(key, value)

0 commit comments

Comments
 (0)