diff --git a/AUTHORS.rst b/AUTHORS.rst index b67a735..e0f80c0 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -30,6 +30,7 @@ Code contributions: - Michał Górny (mgorny) - Serge Lu (Serge45) - Eric Prestat (ericpre) +- Gabriel Mitelman Tkacz (gtkacz) diff --git a/CHANGES.rst b/CHANGES.rst index 0272697..3029993 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Changelog ========= +Version 7.1.2 +------------- + +* Fixing #261 altering all `__repr__` methods so that subclassing will output the correct class name + Version 7.1.1 ------------- diff --git a/box/box.py b/box/box.py index 158a55e..191903e 100644 --- a/box/box.py +++ b/box/box.py @@ -777,7 +777,7 @@ def popitem(self): return key, self.pop(key) def __repr__(self) -> str: - return f"Box({self})" + return f"{self.__class__.__name__}({self})" def __str__(self) -> str: return str(self.to_dict()) diff --git a/box/box_list.py b/box/box_list.py index 048b014..5a983b8 100644 --- a/box/box_list.py +++ b/box/box_list.py @@ -133,7 +133,7 @@ def _dotted_helper(self) -> List[str]: return keys def __repr__(self): - return f"BoxList({self.to_list()})" + return f"{self.__class__.__name__}({self.to_list()})" def __str__(self): return str(self.to_list()) diff --git a/box/config_box.py b/box/config_box.py index 0202ca3..4c48877 100644 --- a/box/config_box.py +++ b/box/config_box.py @@ -124,7 +124,7 @@ def getfloat(self, item, default=None): return self.float(item, default) def __repr__(self): - return "ConfigBox({0})".format(str(self.to_dict())) + return f"{self.__class__.__name__}({str(self.to_dict())})" def copy(self): return ConfigBox(super().copy()) diff --git a/box/shorthand_box.py b/box/shorthand_box.py index 99dfc8d..a82edbd 100644 --- a/box/shorthand_box.py +++ b/box/shorthand_box.py @@ -44,7 +44,7 @@ def toml(self) -> str: return self.to_toml() def __repr__(self): - return f"SBox({self})" + return f"{self.__class__.__name__}({self})" def copy(self) -> "SBox": return SBox(super(SBox, self).copy()) @@ -66,4 +66,4 @@ def __new__(cls, *args, **kwargs): return obj def __repr__(self) -> str: - return f"DDBox({self})" + return f"{self.__class__.__name__}({self})"