✨ Features
- Plain-text formatting for logs and snapshots, plus a Rich renderable path for width-aware console output.
- Built-in handling for common containers,
fieldz-compatible models, and objects with__rich_repr__. - Lazy summaries for NumPy, JAX, Torch, and Warp arrays when those libraries are already imported.
- Shared-reference and cycle tracking for referencable objects such as mappings, sets, frozensets, and custom containers.
- A small customization surface through
__pretty__(),register_type(),register_func(), andregister_lazy(). - Environment-backed defaults through
PRETTY_*, with per-call overrides for logs, snapshots, tests, and interactive debugging.
📦 Installation
uv add liblaf-pretty
# or
pip install liblaf-pretty
🧪 Quick Start
Use pformat() when you want stable plain text:
from liblaf.pretty import pformat
print(pformat({"alpha": [1, 2, 3]}), end="")
{'alpha': [1, 2, 3]}
Use plower() when you want a Rich renderable whose layout is chosen later by
the target Console. If you already have a console, use pprint() or its alias
pp() for the print-now path.
🎛️ Configuration
The public formatting helpers accept per-call overrides for:
max_level,max_list,max_array,max_dictmax_string,max_long,max_otherindenthide_defaults
Those values can also come from environment variables:
export PRETTY_MAX_LIST=2
export PRETTY_INDENT='[bold]>>[/] '
indent accepts plain text, Rich markup, ANSI-colored strings, or
rich.text.Text.
🔢 Arrays
Array libraries are optional. Once NumPy, JAX, Torch, or Warp is already loaded,
liblaf.pretty formats small arrays as compact dtype-and-shape summaries:
import numpy as np
from liblaf.pretty import pformat
print(pformat(np.zeros((2, 3), dtype=np.float32)), end="")
f32[2,3](numpy)
If any dimension is larger than max_array, the formatter falls back to the
object's normal repr instead of importing or traversing large values.
🔁 Shared References
Repeated referencable objects are annotated on first appearance and then render
as <Type @ hexid> references later in the output. Lists and tuples stay safe
too, but they repeat their value instead of collapsing into a reference tag.
🧩 Custom Formatting
Reach for the smallest hook that matches the job:
- Implement
__pretty__(self, ctx)when you own the class. - Use
register_type()for a concrete type and its subclasses. - Use
register_func()for structural matching. - Use
register_lazy()for optional dependencies that should only activate after their module is already imported.
PrettyContext gives custom formatters the builder helpers they usually need:
ctx.container(), ctx.leaf(), ctx.positional(), ctx.name_value(), and
ctx.key_value().
For the full walkthrough, see the custom formatter guide.
🛠️ Development
Common workflows:
mise run lint
mise run docs:build
mise run docs:serve
mise run gen:ref-pages
nox
nox runs the test matrix across Python 3.12, 3.13, and 3.14, with both
highest and lowest-direct dependency resolution.
📝 License
Metadata
Release files for liblaf-pretty 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| liblaf_pretty-0.2.0.tar.gz | 22.7 kB | With provenance | Details for liblaf_pretty-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| liblaf_pretty-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for liblaf_pretty-0.2.0-py3-none-any.whl |
Total release size: 68.4 kB
Release files / liblaf_pretty-0.2.0.tar.gz
| Download URL | liblaf_pretty-0.2.0.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
335fe1985a488fe7903bdf2a3dcec8996037b340db17db87b36f94a1921979ef
|
|
BLAKE2b-256 checksum How to use checksums |
3b0d98f54b92677bfff585574d32d1ff7777cd21df77fd3fd63b2a39a7f41a7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 May 5, 2026.
Transparency logRelease files / liblaf_pretty-0.2.0-py3-none-any.whl
| Download URL | liblaf_pretty-0.2.0-py3-none-any.whl |
|---|---|
| Size | 45.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ace1f75120c52babe4ba82a63aa0c71340b94aa651892e949b5152e2a8d0e8d2
|
|
BLAKE2b-256 checksum How to use checksums |
22fc463736ab283f35a8844fe4d342d25229b276b771db0f78899d2fc59e0274
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 May 5, 2026.
Transparency logSecurity for liblaf-pretty 0.2.0
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.
Attestation for liblaf_pretty-0.2.0.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 May 5, 2026.
Transparency logA 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.