Reading the repo
Reading the repo
Assembly instructions
Rich is a Python library for rich text and beautiful formatting in the terminal.
Saved setup from 11 h ago
Will it work on my device?
Rich works with Linux, macOS and Windows. True color / emoji works with new Windows Terminal, classic terminal is limited to 16 colors. Rich requires Python 3.8 or later.
Rich works with Jupyter notebooks with no additional configuration required.
CONTRIBUTING.mdThis project welcomes contributions in the form of Pull Requests. For clear bug-fixes / typos etc. just submit a PR. For new features or if there is any doubt in how to fix a bug, you might want to open an issue prior to starting work, or email willmcgugan+rich@gmail.com to discuss it first.
See also AI_POLICY.md if you will be using AI.
Rich uses poetry for packaging and dependency management. To start developing with Rich, install Poetry using the recommended method.
Next, you'll need to create a fork (your own personal copy) of the Rich repository, and clone that fork on to your local machine. GitHub offers a great tutorial for this process here. After following this guide, you'll have a local copy of the Rich project installed.
Enter the directory containing your copy of Rich (cd rich).
Next create and activate a virtual environment for Rich.
Now we can install the dependencies of Rich into the virtual environment:
poetry install
The rest of this guide assumes you're inside the virtual environment.
If you're having difficulty running any of the commands that follow,
ensure you're inside the virtual environment by running poetry shell.
At this point, you're ready to start developing. Some things to consider while developing Rich code include:
Before each commit, you should:
blackThese steps are described in the following sections.
Run tests with the following command:
make test
Or if you don't have make, run the following:
pytest --cov-report term-missing --cov=rich tests/ -vv
New code should ideally have tests and not break existing tests.
The "Coverage Report" that gets printed to the terminal after the tests run can be used to identify lines of code that haven't been covered by tests. If any of the new lines you've added or modified appear in this report, you should strongly consider adding tests which exercise them.
Rich uses type annotations throughout, and mypy to do the checking.
Run the following to type check Rich:
make typecheck
Or if you don't have make:
mypy -p rich --config-file= --ignore-missing-imports --no-implicit-optional --warn-unreachable
Please add type annotations for all new code, and ensure that type checking succeeds before creating a pull request.
Rich uses black for code formatting.
I recommend setting up black in your editor to format on save.
To run black from the command line, use make format-check to check your formatting,
and use make format to format and write to the files.
Consider whether the change you made would benefit from documentation - if the feature has any user impact at all, the answer is almost certainly yes!
Documentation can be found in the docs directory.
There are some additional dependencies required to build the documentation.
These dependencies can be installed by running (from the docs directory):
pip install -r requirements.txt
After updating the documentation, you can build them (from the project root directory) by running:
make docs
This will generate the static HTML for the documentation site at docs/build/html.
Before submitting your pull request, update the CHANGELOG.md file describing, briefly, what you've done.
Be sure to follow the format seen in the rest of the document.
If this is your first time contributing to Rich:
CONTRIBUTORS.md.We strongly recommend you install the pre-commit hooks included in the repository.
These automatically run some of the checks described earlier each time you run git commit,
and over time can reduce development overhead quite considerably.
Once you're happy with your change and have ensured that all steps above have been followed (and checks have passed), you can create a pull request. GitHub offers a guide on how to do this here. Please ensure that you include a good description of what your change does in your pull request, and link it to any relevant issues or discussions.
When you create your pull request, we'll run the checks described earlier. If they fail, please attempt to fix them as we're unlikely to be able to review your code until then. If you've exhausted all options on trying to fix a failing check, feel free to leave a note saying so in the pull request and someone may be able to offer assistance.
After the checks in your pull request pass, someone will review your code. There may be some discussion and, in most cases, a few iterations will be required to find a solution that works best.
When the pull request is approved, it will be merged into the master branch.
Your change will only be available to users the next time Rich is released.
Then run bash setup.sh. It stops at the first error and is safe to run again. Servers and tests aren't started; it lists them at the end. Read it first.
Compare yours with the README's “Compatibility” list above before installing anything.
Needs Git: xcode-select --install
git clone https://github.com/Textualize/rich.git cd rich
Python >=3.9.0
brew install python@3.9 pipx install poetry
poetry install
poetry run pytest
For more control over rich terminal content, import and construct a Console object.
from rich.console import Console
console = Console()
The Console object has a print method which has an intentionally similar interface to the builtin print function. Here's an example of use:
console.print("Hello", "World!")
As you might expect, this will print "Hello World!" to the terminal. Note that unlike the builtin print function, Rich will word-wrap your text to fit within the terminal width.
There are a few ways of adding color and style to your output. You can set a style for the entire output by adding a style keyword argument. Here's an example:
console.print("Hello", "World!", style="bold red")
The output will be something like the following:

That's fine for styling a line of text at a time. For more finely grained styling, Rich renders a special markup which is similar in syntax to bbcode. Here's an example:
console.print("Where there is a [bold cyan]Will[/bold cyan] there [u]is[/u] a [i]way[/i].")

You can use a Console object to generate sophisticated output with minimal effort. See the Console API docs for details.
No reports for macOS yet.
Opens a chat with this manual already filled in, for macOS. It uses your own account; gitmanual sends nothing.