Open alexklapheke opened 1 year ago
Describe the bug
I have the same bug. And the bug exists not only IPython but also in Python REPL.
The last output uses the default highlighter ReprHighlighter()
instead of RainbowHighlighter()
It might be a bug that the evaluated results of any REPL ignores the custom options of the console.
The output format of REPL evaluated result is decided by sys.displayhook
. And rich.pretty.install()
installs to the global console by assigning display_hook
to it. However the implementation of display_hook
prints the Pretty value without setting the options to theconsole
's. Therefore, specifying the param highlighter
to the console's highlighter fix it. And I hope that the customization of console options will be synchronized to the REPL output in the future.
Platform
Describe the bug
Not sure if it's a bug per se, but it was unexpected behavior. I wanted to add some custom highlighting rules to iPython, so I made a custom highlighter object and added the following to
~/.ipython/profile_default/startup/
:The custom highlighting shows up in
rich.print
, but not in theOut[]
cells. It seems like the iPython display hook is using it's own instance ofReprHighlighter
and not the one fromget_console()
. This is the workaround I found:Platform