Skip to content

Commit

Permalink
Merge pull request #1274 from nathanrpage97/feat/add-ipython-extension
Browse files Browse the repository at this point in the history
add ipython extension for rich
  • Loading branch information
willmcgugan committed Jun 9, 2021
2 parents 7592f09 + 9a65f49 commit 2002463
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [10.3.0] - Unreleased
## [10.3.0] - 2021-06-09

### Added

- Added Console.size setter
- Added Console.width setter
- Added Console.height setter
- Added angular style Rich reprs
- Added an IPython extension. Load via `%load_ext rich`

### Changed

- Changed the logic for retrieving the calling frame in console logs to a faster one for the Python implementations that support it.

## [10.2.2] - 2021-05-19


### Fixed

- Fixed status not rendering console markup https://github.com/willmcgugan/rich/issues/1244
Expand Down
13 changes: 11 additions & 2 deletions docs/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ If you would rather not shadow Python's builtin print, you can import ``rich.pri

Continue reading to learn about the more advanced features of Rich.

Python in the REPL
------------------
Rich in the REPL
----------------

Rich may be installed in the REPL so that Python data structures are automatically pretty printed with syntax highlighting. Here's how::

Expand All @@ -85,6 +85,15 @@ You can also use this feature to try out Rich *renderables*. Here's an example::

Read on to learn more about Rich renderables.

IPython Extension
~~~~~~~~~~~~~~~~~

Rich also includes an IPython extension that will do this same pretty install + pretty tracebacks. Here's how to load it::

In [1]: %load_ext rich
You can also have it load by default by adding `"rich"` to the ``c.InteractiveShellApp.extension`` variable in
`IPython Configuration <https://ipython.readthedocs.io/en/stable/config/intro.html>`_.

Rich Inspect
------------
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ authors = ["Will McGugan <willmcgugan@gmail.com>"]
license = "MIT"
readme = "README.md"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Framework :: IPython",
"Intended Audience :: Developers",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",
Expand All @@ -19,19 +20,18 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Typing :: Typed"
"Typing :: Typed",
]
include = ["rich/py.typed"]


[tool.poetry.dependencies]
python = "^3.6"
typing-extensions = {version = "^3.7.4", python = "<3.8"}
dataclasses = {version=">=0.7,<0.9", python = "~3.6"}
typing-extensions = { version = "^3.7.4", python = "<3.8" }
dataclasses = { version = ">=0.7,<0.9", python = "~3.6" }
pygments = "^2.6.0"
commonmark = "^0.9.0"
colorama = "^0.4.0"
ipywidgets = {version = "^7.5.1", optional = true}
ipywidgets = { version = "^7.5.1", optional = true }


[tool.poetry.extras]
Expand Down
4 changes: 3 additions & 1 deletion rich/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Rich text and beautiful formatting in the terminal."""

import os
from typing import Any, IO, Optional, TYPE_CHECKING
from typing import IO, TYPE_CHECKING, Any, Optional

from ._extension import load_ipython_extension

__all__ = ["get_console", "reconfigure", "print", "inspect"]

Expand Down
10 changes: 10 additions & 0 deletions rich/_extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import Any


def load_ipython_extension(ip: Any) -> None: # pragma: no cover
# prevent circular import
from rich.pretty import install
from rich.traceback import install as tr_install

install()
tr_install()

0 comments on commit 2002463

Please sign in to comment.