Skip to main content

wadler-lindig-parts

A parts layer over wadler-lindig: one engine behind repr, str, __format__ and the representations Jupyter asks for.

A type joins in by saying what it is made of, not how it renders. Register pparts and the type gets every markup, every value form and the per-element format spec — including axes added later by somebody else.

>>> import dataclasses
>>> from wadler_lindig_parts import PPart, ReprMixin, pparts

>>> @dataclasses.dataclass(repr=False)  # repr=True would shadow the mixin
... class Version(ReprMixin):
...     major: int
...     minor: int
...     __repr_spec__ = "bare"

>>> @pparts.dispatch
... def _(obj: Version, /, *, markup="text", **kw):
...     return (
...         PPart("major", str(obj.major)),
...         PPart("dot", ".", "sep"),
...         PPart("minor", str(obj.minor)),
...     )

>>> Version(2, 1)
2.1
>>> f"{Version(2, 1):html}"
'<span>2</span>.<span>1</span>'
>>> f"{Version(2, 1):latex}"
'$2.1$'

One pparts method; four output routes, and they cannot disagree.

Install

pip install wadler-lindig-parts

Two runtime dependencies, wadler-lindig and plum-dispatch, and nothing else — ever. A test parses every module and fails on any import outside that set plus the standard library, so a third dependency cannot be added without someone deliberately deleting that test.

Register axes before defining classes that name them

ReprMixin resolves __repr_spec__ when the class is created, not at first print. So a spec naming an axis or alias that is not yet registered fails at the class statement:

>>> from wadler_lindig_parts import Axis, register_axis, unregister_axis

>>> try:
...     class TooEarly(ReprMixin):
...         __repr_spec__ = "call-vecform"
... except ValueError as e:
...     print("class creation failed:", str(e).split(":")[0])
class creation failed: invalid format spec 'call-vecform'

>>> _ = register_axis(Axis(
...     name="vector_form",
...     keywords={"vecform": True},
...     default=False,
...     layouts={"call": lambda v: {"vector_form": v}},
... ))
>>> class NowFine(ReprMixin):
...     __repr_spec__ = "call-vecform"
>>> NowFine._repr_spec_parsed["vector_form"]
True
>>> unregister_axis("vector_form")

Inside one package that was a statement about the order of lines in an __init__.py. Between two installed distributions it is load order between them: register your axes at import of your own package, before importing or defining the classes whose repr specs use them. The error arrives at a class statement that looks unrelated to the registration, which is why it is written down here rather than left to the message.

Keywords share one flat namespace

Every registering distribution writes into the same keyword index, so a run of keywords can be written in any order — html-bare and bare-html are the same request. Two packages may want the same word, and both registrations succeed: the bare word then raises and names both claimants, while axis=word keeps working for each.

A collision therefore costs one word in one spec, not a rewrite and not a registration. A package expecting to share vocabulary can write the qualified form from the start.

Documentation

https://galacticdynamics.github.io/wadler-lindig-parts

Metadata

Release files for wadler-lindig-parts 0.1.0

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

Source distribution (sdist)

Source distribution for wadler-lindig-parts 0.1.0
File Size Uploaded Provenance Actions
wadler_lindig_parts-0.1.0.tar.gz 45.8 kB With provenance Details for wadler_lindig_parts-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wadler-lindig-parts 0.1.0
File Interpreter ABI Platform Actions
wadler_lindig_parts-0.1.0-py3-none-any.whl Python 3 none any Details for wadler_lindig_parts-0.1.0-py3-none-any.whl

Total release size: 71.5 kB

Release files / wadler_lindig_parts-0.1.0.tar.gz

Download URL wadler_lindig_parts-0.1.0.tar.gz
Size 45.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e9961520b09ca7bcf60925edfa7f65515eb24b887ae5e5c32c86f2032d798f26
BLAKE2b-256 checksum
How to use checksums
03a5997fcb29762440083f3204da6d060d1ed33d15a0253fde1deedf9b81f8d4
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 Nov 3, 2026.

Transparency log

Release files / wadler_lindig_parts-0.1.0-py3-none-any.whl

Download URL wadler_lindig_parts-0.1.0-py3-none-any.whl
Size 25.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5eecd211718c4a07819bef6dfc1cd3df534e2e66df1fcca0ab49ae9868ffb484
BLAKE2b-256 checksum
How to use checksums
8919538eac75f759753183e1a15a66f2e69d1ef60934f7953ca0a22c0eb8ec78
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 Nov 3, 2026.

Transparency log

Security for wadler-lindig-parts 0.1.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wadler_lindig_parts-0.1.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 Nov 3, 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