You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When rich is installed as an ipython plugin output %lsmagic fails to output anything meaningful:
In [21]: %lsmagic
Out[21]: <IPython.core.magics.basic.MagicsDisplay object at 0x10d0a39e0>
This is because __repr__ instead of __str__ is being used on the MagicsDisplay object. The MagicsDisplay have a special method_repr_pretty_. If you update MagicsDisplay and include:
def __repr__(self):
return self._lsmagic()
All is well.
Should rich look for _repr_pretty_ and use instead of __str__ or should ipython update MagicsDisplay?
Seems fixed on ipython/ipython#14378 side, given that there is standard interface for this there should be no need for rich to implement support for custom interface of various projects, right?
Describe the bug
When
rich
is installed as an ipython plugin output%lsmagic
fails to output anything meaningful:This is because
__repr__
instead of__str__
is being used on theMagicsDisplay
object. TheMagicsDisplay
have a special method_repr_pretty_
. If you updateMagicsDisplay
and include:All is well.
Should
rich
look for_repr_pretty_
and use instead of__str__
or should ipython updateMagicsDisplay
?Platform
Click to expand
``` ╭───────────────────────── ─────────────────────────╮ │ A high level console interface. │ │ │ │ ╭──────────────────────────────────────────────────────────────────────────────╮ │ │ │ │ │ │ ╰──────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ color_system = 'truecolor' │ │ encoding = 'utf-8' │ │ file = <_io.TextIOWrapper name='' mode='w' encoding='utf-8'> │ │ height = 53 │ │ is_alt_screen = False │ │ is_dumb_terminal = False │ │ is_interactive = True │ │ is_jupyter = False │ │ is_terminal = True │ │ legacy_windows = False │ │ no_color = False │ │ options = ConsoleOptions( │ │ size=ConsoleDimensions(width=140, height=53), │ │ legacy_windows=False, │ │ min_width=1, │ │ max_width=140, │ │ is_terminal=True, │ │ encoding='utf-8', │ │ max_height=53, │ │ justify=None, │ │ overflow=None, │ │ no_wrap=False, │ │ highlight=None, │ │ markup=None, │ │ height=None │ │ ) │ │ quiet = False │ │ record = False │ │ safe_box = True │ │ size = ConsoleDimensions(width=140, height=53) │ │ soft_wrap = False │ │ stderr = False │ │ style = None │ │ tab_size = 8 │ │ width = 140 │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭─── ────╮ │ Windows features available. │ │ │ │ ╭───────────────────────────────────────────────────╮ │ │ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │ │ ╰───────────────────────────────────────────────────╯ │ │ │ │ truecolor = False │ │ vt = False │ ╰───────────────────────────────────────────────────────╯ ╭────── Environment Variables ───────╮ │ { │ │ 'TERM': 'xterm-256color', │ │ 'COLORTERM': 'truecolor', │ │ 'CLICOLOR': 'true', │ │ 'NO_COLOR': None, │ │ 'TERM_PROGRAM': 'tmux', │ │ 'COLUMNS': None, │ │ 'LINES': None, │ │ 'JUPYTER_COLUMNS': None, │ │ 'JUPYTER_LINES': None, │ │ 'JPY_PARENT_PID': None, │ │ 'VSCODE_VERBOSE_LOGGING': None │ │ } │ ╰────────────────────────────────────╯ platform="Darwin" rich==13.7.1 ```The text was updated successfully, but these errors were encountered: