{"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":"python","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,"search_vec":"'1.2.7':56 'add':67 'addit':16 'altern':43 'class':28 'compat':63 'consol':27,74 'console-output':73 'current':52 'custom':26 'enhanc':69 'enrich':1,5 'extend':7 'extens':3 'featur':17 'format':76 'function':9 'implicit':36 'includ':20 'librari':6,14 'log':46,71 'maintain':62 'minor':68 'nativ':19 'occur':59 'offer':24 'output':75 'period':60 'popular':12 'priorit':48 'provid':15 'redirect':32,78 'releas':58 'rich':2,13,22,65,70 'richhandl':44 'soft':37,49 'stabl':53 'support':30 'sys.stderr':34 'sys.stdout':33,77 'termin':72 'version':54 'well':40 'wrap':38,50","created_at":"2026-04-12T03:36:15.375987+00:00","updated_at":"2026-04-16T14:49:13.677865+00:00","problems":[{"fix":"Install the library using pip: `pip install enrich`","cause":"The 'enrich' library is not installed in the current Python environment, or the environment where the code is being run does not have access to the installed library.","error":"ModuleNotFoundError: No module named 'enrich'"},{"fix":"Ensure you are importing and using the `Console` class from `enrich.console` instead of `rich.console`: `from enrich.console import Console`","cause":"This error occurs when attempting to use the `redirect=True` argument with the standard `rich.console.Console` class, but this specific argument is an enhancement provided only by the `enrich.console.Console` class.","error":"TypeError: __init__() got an unexpected keyword argument 'redirect'"},{"fix":"Import and use the `Console` class from `enrich.console` to leverage its soft-wrapping capabilities: `from enrich.console import Console`","cause":"This error arises when trying to pass the `soft_wrap=True` argument directly to the `rich.console.Console` constructor. Implicit soft wrapping in the `Console` constructor is a feature added by the `enrich` library.","error":"TypeError: __init__() got an unexpected keyword argument 'soft_wrap'"},{"fix":"Remove the `soft_wrap` argument when initializing `enrich.logging.RichHandler`, as its soft-wrapping is managed internally. For example: `from enrich.logging import RichHandler; handler = RichHandler()`","cause":"The `enrich.logging.RichHandler` inherently provides soft-wrapping behavior by internally using an `enrich.console.Console` instance configured for it. Passing `soft_wrap` as an explicit argument to the `RichHandler` constructor is not supported.","error":"TypeError: __init__() got an unexpected keyword argument 'soft_wrap'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.2.7","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/pycontribs/enrich","docs":null,"changelog":null,"pypi":"https://pypi.org/project/enrich/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}