{"id":3989,"library":"enrich","title":"Enrich (Rich Extensions)","description":"The `enrich` library extends the functionality of the popular `rich` library, providing additional features not natively included in `rich`. It offers a custom `Console` class with support for redirecting `sys.stdout`/`sys.stderr` and implicit soft wrapping, as well as an alternative `RichHandler` for logging that prioritizes soft wrapping. The current stable version is 1.2.7, with releases occurring periodically to maintain compatibility with `rich` and add minor enhancements.","status":"active","version":"1.2.7","language":"en","source_language":"en","source_url":"https://github.com/pycontribs/enrich","tags":["rich","logging","terminal","console-output","formatting","sys.stdout-redirection"],"install":[{"cmd":"pip install enrich","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency; 'enrich' extends 'rich' functionality.","package":"rich","optional":false}],"imports":[{"note":"The `enrich` Console class includes additional features like `redirect` and `soft_wrap` parameters not present in the original `rich.console.Console`.","wrong":"from rich.console import Console","symbol":"Console","correct":"from enrich.console import Console"},{"note":"The `enrich` RichHandler provides an alternative logging handler, notably with soft-wrapping behavior, differing from the standard `rich` handler.","wrong":"from rich.logging import RichHandler","symbol":"RichHandler","correct":"from enrich.logging import RichHandler"}],"quickstart":{"code":"import logging\nfrom enrich.console import Console\nfrom enrich.logging import RichHandler\nimport sys\n\n# Example 1: Console with redirect support\nconsole_redirect = Console(redirect=True, record=True)\noriginal_stdout = sys.stdout\nsys.stdout = console_redirect.fileproxy\n\nprint(\"This output is redirected and recorded.\")\nsys.stdout = original_stdout # Restore stdout\n\n# print(f\"Captured output: {console_redirect.export_text()}\") # Use this to see recorded text\n\n# Example 2: Console with implicit soft wrapping\nconsole_soft_wrap = Console(soft_wrap=True)\nconsole_soft_wrap.print(\"This is a very long line of text that will be soft-wrapped by the console instance, ensuring it fits within any terminal width without explicit print arguments.\")\n\n# Example 3: Soft-wrapping logger\nFORMAT = \"%(message)s\"\nlogging.basicConfig(\n    level=\"INFO\", format=FORMAT, handlers=[RichHandler(soft_wrap=True)]\n)\nlog = logging.getLogger(\"my_app\")\nlog.info(\"This log message will also be soft-wrapped.\")\nlog.info(\"Another long message demonstrating the soft-wrapping logger functionality.\")","lang":"python","description":"This quickstart demonstrates key features of the `enrich` library: a `Console` instance configured to redirect `sys.stdout` and capture output, another `Console` instance with implicit soft-wrapping enabled for print statements, and the `RichHandler` configured for soft-wrapping in standard Python logging."},"warnings":[{"fix":"Ensure your project uses Python 3.9 or higher when upgrading to `enrich` version 1.3.0 or later. For current versions (1.2.x), Python 3.6+ is sufficient.","message":"Future versions (v1.3.0+) will require Python 3.9 or newer. Version 1.2.7 (and earlier) supports Python 3.6+.","severity":"breaking","affected_versions":">=1.3.0"},{"fix":"Always import `Console` and `RichHandler` from `enrich.console` and `enrich.logging` respectively, to access the extended functionality.","message":"The `Console` and `RichHandler` classes from `enrich` are distinct from their `rich` counterparts. Using `from rich.console import Console` will *not* provide the `enrich`-specific features like `redirect` or `soft_wrap` parameters.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to `enrich`'s release notes (e.g., 'Avoid incompatible version of rich' in v1.2.4) and its `pyproject.toml` or `setup.py` for exact `rich` version compatibility. Upgrade `rich` cautiously or allow `enrich` to manage its `rich` dependency.","message":"The `enrich` library is built upon `rich`, and breaking changes or incompatibilities in `rich` itself can affect `enrich` users. Specific versions of `enrich` might pin compatible `rich` versions.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}