Rich is a Python library for rich text and beautiful formatting in the terminal.
MIT License
Bot releases are visible (Hide)
### Added
The highlight of this version is the new option to render 'indent guides' in Syntax and pretty printing.
I've also added a max_length
argument to pretty printing which will truncate containers longer than a certain length.
Published by willmcgugan about 4 years ago
The highlights of Rich 9.0.0 would be a new pager method which will pipe any console output in to the system 'pager'. See this tweet for an example. There's also a new Bar
renderable you could use to display a chart in a table. See bars.py for an example of how to use it.
Note this is a major version release so there are some breaking changes to the API -- these are unlikely to impact many people, but please check the changelog below.
Style.transparent_background
method name.Published by willmcgugan about 4 years ago
The highlight of this release is the option to show local variables in tracebacks.
### Added
Published by willmcgugan about 4 years ago
The highlight of this release is some improvements to Rich tracebacks. The traceback display makes better use of space and handle long paths better. Rich tracebacks can also be rendered in Rich's logging handler which is much easier to read (thanks to @taliraj for his PR for this feature).
### Changed
Published by willmcgugan about 4 years ago
The main feature of this release was a way of display syntax highlighting with only standard colors (i.e. the colors you can configure in the terminal), which you can do by setting the theme to "ansi_dark" or "ansi_light". The other themes are generally prettier (IMHO) but use colors defined by the theme, and not by the user's settings.
When testing the above I also made some optimizations which benefit all the Rich output. You may only notice this if you are syntax highlighting large XML files, but its faster now.
This is a major release as there were a small number of signature changes. Most people won't be impacted, but please review the release notes below.
### Changed
Published by willmcgugan about 4 years ago
Published by willmcgugan about 4 years ago
#
sign is included in url highlightingThis release adds a function called inspect
which uses rich to display the data / methods / docs for any Python object.
I think this is a fantastic debug aid, and I'm looking forward to using it in other projects.
Published by willmcgugan about 4 years ago
Headline of this release is a better pretty print. The previous version could expand lines prematurely. This version fits containers and is faster to boot. It also support defaultdict, Counter, and array.
Breaking change is because the signature of Pretty and pretty_repr has changed, and the character
argument to rule was dropped. This is unlikely to impact many people.
__rich__
castcharacter
parameter in Rule and Console.rule, in favor of characters
Published by willmcgugan about 4 years ago
Version 5.20 adds the ability to disable cropping to the console width, in effect allowing the terminal to soft wrap lines.
Also in 5.20 is the ability to specify multiple characters in a Rule.
Published by willmcgugan about 4 years ago
Published by willmcgugan about 4 years ago
This release adds a home grown pretty print formatter, and removes the pprintpp dependancy. The new formatter is better integrated with Rich and will be a more flexible solution, but its not as battle tested as pprintpp. Please report any bugs!
Also in 5.1.0 is a 'display hook' which allows for integration of Rich in to the REPL, so all your data will be pretty. It's kind of fun to use.
The following will install the display hook.
>>> from rich import pretty
>>> pretty.install()
Published by willmcgugan about 4 years ago
Console markup syntax has been tweaked to not overlap with Python data structures.
Prior to 5.0.0 if you stringified a list it would typically be removed from the output as Rich would interpret it as a markup tag. This surprised people when printing lists in an f-string.
For instance, prior to 5.0.0 the following would not print as you might expect:
>>> my_list = [1,2,3]
>>> print(f"my_list={my_list}")
my_list=
With 5.0.0 it prints this following::
my_list = [1, 2, 3]
Which is less astonishing.
This change required some changes to the console markup syntax, which is the reason for the major version bump.
You can no longer use a number between 0 and 255 to provide a color, now it must be wrapped with color(NUMBER)
. So "[4]Red[/]"
becomes "[color(4)]Red[/]"
. From an extensive search of Github, most people never used this syntax anyway and would prefer to use friendly color names.
Additionally escaping has changed. Prior to 5.0.0 you could escape square brackets by doubling them up. From 5.0.0 you can escape a tag with backslash.
[1,2,3]
is treated as a literal, not a tag."color(<number>)"
so that [5]
(for example) is considered a literal.foo[[]]
would be foo\[bar]
Published by willmcgugan about 4 years ago