From 41b328882172aafddd6c16ee6260df1177a5319b Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Thu, 14 Nov 2024 10:18:48 -0600 Subject: [PATCH] LazilyUnpickling{Dict,List}: add __repr__ (#817) * LazilyUnpickling{Dict,List}: better repr * add type to repr of PickledObject --- loopy/tools.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/loopy/tools.py b/loopy/tools.py index bf7785fcf..bb4904bf2 100644 --- a/loopy/tools.py +++ b/loopy/tools.py @@ -348,6 +348,9 @@ def unpickle(self): def __getstate__(self): return {"objstring": self.objstring} + def __repr__(self) -> str: + return type(self).__name__ + "(" + repr(self.unpickle()) + ")" + class _PickledObjectWithEqAndPersistentHashKeys(_PickledObject): """Like :class:`_PickledObject`, with two additional attributes: @@ -406,6 +409,9 @@ def __getstate__(self): key: _PickledObject(val) for key, val in self._map.items()}} + def __repr__(self) -> str: + return type(self).__name__ + "(" + repr(self._map) + ")" + # }}} @@ -444,6 +450,9 @@ def __add__(self, other): def __mul__(self, other): return self._list * other + def __repr__(self) -> str: + return type(self).__name__ + "(" + repr(self._list) + ")" + class LazilyUnpicklingListWithEqAndPersistentHashing(LazilyUnpicklingList): """A list which lazily unpickles its values, and supports equality comparison