Skip to content

Commit

Permalink
fix subclass has no access to super class attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhiyuanChen committed Nov 28, 2022
1 parent b070a11 commit 2280203
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions chanfig/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,12 @@ def getattr(self, name: str, default: Optional[Any] = None):
"""

try:
try:
if name in self.__dict__:
return self.__dict__[name]
except KeyError:
if name in self.__class__.__dict__:
return self.__class__.__dict__[name]
except KeyError:
return super().getattr(name, default) # type: ignore
except AttributeError:
if default is not None:
return default
raise AttributeError(f"{self.__class__.__name__} has no attribute {name}") from None
Expand Down

0 comments on commit 2280203

Please sign in to comment.