-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
bugSomething isn't workingSomething isn't working
Description
When one of the items in a mapping is named "items", the __repr__ fails.
That's because items() method is called on the object in _data_for_repr()
attmap/attmap/_att_map_like.py
Lines 165 to 173 in 54b943e
| def _data_for_repr(self): | |
| """ | |
| Hook for extracting the data used in the object's text representation. | |
| :return Iterable[(hashable, object)]: collection of key-value pairs | |
| to include in object's text representation | |
| """ | |
| return filter(lambda kv: not self._excl_from_repr(kv[0], self.__class__), | |
| self.items()) |
In [35]: AttMap({'attr1': 'val1', 'items': {'attr2_1': 'string'}})
Out[35]: ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
700 type_pprinters=self.type_printers,
701 deferred_pprinters=self.deferred_printers)
--> 702 printer.pretty(obj)
703 printer.flush()
704 return stream.getvalue()
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/lib/pretty.py in pretty(self, obj)
397 meth = cls._repr_pretty_
398 if callable(meth):
--> 399 return meth(obj, self, cycle)
400 if cls is not object \
401 and callable(cls.__dict__.get('__repr__')):
~/code/attmap/attmap/attmap.py in _repr_pretty_(self, p, cycle)
121 :return str: text representation of the instance
122 """
--> 123 return p.text(repr(self) if not cycle else '...')
~/code/attmap/attmap/_att_map_like.py in __repr__(self)
64 def __repr__(self):
65 return self._render(self._simplify_keyvalue(
---> 66 self._data_for_repr(), self._new_empty_basic_map))
67
68 def _render(self, data, exclude_class_list=[]):
~/code/attmap/attmap/_att_map_like.py in _data_for_repr(self)
171 """
172 return filter(lambda kv: not self._excl_from_repr(kv[0], self.__class__),
--> 173 self.items())
174
175 def _excl_from_eq(self, k):
TypeError: 'AttMap' object is not callable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working