epy.pretty_repr_top_level

epy.pretty_repr_top_level#

etils.epy.pretty_repr_top_level(obj: Any, *, force: bool = False) str[source]#

Pretty repr(obj) for nested list, dict, dataclasses,…

This version do not use @reprlib.recursive_repr() to avoid bug when used inside __repr__:

class A:
  def __repr__(self):
    return epy.pretty_repr_top_level(self)

epy.pretty_repr(A())  # Do not display `...`
Parameters:
  • obj – Object to display

  • force – Force the pretty_repr, even if the object has a custom __repr__. This is useful when the __repr__ implementation itself want to call pretty_repr(self).

Returns:

Repr