Skip to main content

rich-objects

This is a small set of tools to help provide easy to use, flexible tools for display complex objects for a CLI.

Getting started

The project has been published to PyPi, so you should be able to install it with something like one of the following (depending on how you do Python package management):

% pip install rich-objects
% uv add rich-objects

The sections below provide a brief description with links to more examples and details.

Background

This module extends the rich module to provide pretty printing of complex data objects. The most common use case is a CLI that displays the json/yaml data that is returned to a CLI client in several different formats.

The easiest way to leverage this library is using the display() function. You can provide a fmt and style to provide different means of displaying the data.

Here are some of the lower level elements:

  • OutputFormat and OutputSyle are enums suitable to use as a CLI argument to support different displays
  • RichTable class is a thin wrapper derived from rich.Table. It contains some default formatting for the tables, since it becomes confusing when tables are nested.
  • Added several functions starting with rich_table_factory() to create a RichTable with appropriate nesting based on the data returned by the data in the object.
  • The console_factory() is the default means for printing the output, but this just sets the rich.Console width.

Examples

In general, this can be used in any enviroment where CLI output is used. The shell commands below assume the example.py file is executable (e.g. chmod a+x example.py).

Typer Example

Here's a simple Python example to leverage the new code:

#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.9"
# dependencies = [
#     "rich-objects",
#     "typer",
# ]
# ///
from typer import Typer
from rich_objects import OutputFormat, OutputStyle, display

DATA = [
    {"name": "sna", "prop1": 1, "prop B": None, "blah": "zay"},
    {
        "name": "foo",
        "prop2": 2,
        "prop B": True,
    },
    {
        "name": "bar",
        1: "inverse",
    },
]

app = Typer()

@app.command()
def print_data(
    output_fmt: OutputFormat = OutputFormat.TABLE,
    output_style: OutputStyle = OutputStyle.ALL,
    indent: int = 2,
):
    data = DATA  # TODO: figure out how to get your data here
    display(data, fmt=output_fmt, style=output_style, indent=indent)

if __name__ == "__main__":
    app()

Here's some sample output:

(.venv) > ./example.py
┏━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Name ┃ Properties     ┃
┡━━━━━━╇━━━━━━━━━━━━━━━━┩
│ sna  │  prop1   1     │
│      │  prop B  None  │
│      │  blah    zay   │
├──────┼────────────────┤
│ foo  │  prop2   2     │
│      │  prop B  True  │
├──────┼────────────────┤
│ bar  │  1  inverse    │
└──────┴────────────────┘
Found 3 items            
(.venv) > ./example.py --output-fmt json
[
  {
    "name": "sna",
    "prop1": 1,
    "prop B": null,
    "blah": "zay"
  },
  {
    "name": "foo",
    "prop2": 2,
    "prop B": true
  },
  {
    "name": "bar",
    "1": "inverse"
  }
]
(.venv) > ./example.py --output-fmt yaml
- blah: zay
  name: sna
  prop B: null
  prop1: 1
- name: foo
  prop B: true
  prop2: 2
- name: bar
  1: inverse

(.venv) > 

Contributing

This project uses uv for packaging and development:

uv sync
make lint test

If you have any suggestions, please email Rick directly (rickwporter@gmail.com).

Metadata

Release files for rich-objects 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rich-objects 0.3.1
File Size Uploaded Provenance
rich_objects-0.3.1.tar.gz 44.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for rich-objects 0.3.1
File Interpreter ABI Platform
rich_objects-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 54.8 kB

Release files / rich_objects-0.3.1.tar.gz

Download URL rich_objects-0.3.1.tar.gz
Size 44.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f9d9a1ac0b98ac85eb1a1651a65c6aca79b04a12497571f8fd4c03d1b290d943
BLAKE2b-256 checksum
How to use checksums
13e7c7f0c7654a522e7e36017b77733cb011301cfde2cdc78b744704eceaa09e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / rich_objects-0.3.1-py3-none-any.whl

Download URL rich_objects-0.3.1-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e04d5b841cb754c15ab2167778759c40b602881110d5c34afd9a4505bebb6dfc
BLAKE2b-256 checksum
How to use checksums
00bd90e0b758168fee69a37c79354ea4455c9bbe1d5c4270c436185306774d6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for rich-objects 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rich_objects-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page