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 value
format spec — including axes added later by somebody else.
>>> import dataclasses
>>> from wadler_lindig_parts import PPart, pparts, pspec
>>> @dataclasses.dataclass
... class Version:
... major: int
... minor: int
...
... def __repr__(self) -> str:
... return pspec(self, "bare")
...
... def __format__(self, spec: str, /) -> str:
... return pspec(self, spec)
>>> @pparts.dispatch
... def _(obj: Version, /, *, markup="text", **kw):
... return (
... PPart("major", str(obj.major)),
... PPart("dot", ".", "sep"),
... PPart("minor", str(obj.minor)),
... )
>>> v = Version(2, 1)
>>> v
2.1
>>> f"{v:html}"
'<span>2</span>.<span>1</span>'
>>> f"{v:latex}"
'$2.1$'
One pparts method, two lines of plumbing, and four output routes that
cannot disagree.
ReprMixin writes those two methods for you and adds __str__, the Jupyter
hooks and a __pdoc__. Most types do not need a base class for two short
methods, so the examples here write them out; see
how to make a type formattable for both routes side by side.
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
This one is about ReprMixin, which 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, ReprMixin, 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.
A spec written inside __repr__ is parsed on each call instead, so the plain
route has no ordering requirement: the same mistake surfaces at the first
print, naming the spec.
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
New to the package? Make your first formattable type builds one from nothing in a few minutes. Already building something? The how-to guides are task-sized, and the reference has the spec grammar and every public name.
Metadata
Release files for wadler-lindig-parts 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 |
|---|---|---|---|---|
| wadler_lindig_parts-0.2.0.tar.gz | 64.6 kB | With provenance | Details for wadler_lindig_parts-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wadler_lindig_parts-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for wadler_lindig_parts-0.2.0-py3-none-any.whl |
Total release size: 91.3 kB
Release files / wadler_lindig_parts-0.2.0.tar.gz
| Download URL | wadler_lindig_parts-0.2.0.tar.gz |
|---|---|
| Size | 64.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3295bf31d95ea4ea0ad29a7f7c24478aa545d9d49b8ab6bd7529f7b1010c70f
|
|
BLAKE2b-256 checksum How to use checksums |
941bd585b83c5d13b343e1a9505a052c366aabb499ad16b0cddbed8c507a8369
|
| 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 6, 2026.
Transparency logRelease files / wadler_lindig_parts-0.2.0-py3-none-any.whl
| Download URL | wadler_lindig_parts-0.2.0-py3-none-any.whl |
|---|---|
| Size | 26.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75f49cbd70c8d8a0ed3181a467413fa8003d9ccfdf37c0a4884dbaef4d931c0f
|
|
BLAKE2b-256 checksum How to use checksums |
8a24019484594b7925dac8a93c26e3e568ed6519a3cd801ba3b592d3915d9d5a
|
| 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 6, 2026.
Transparency logSecurity for wadler-lindig-parts 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
Both files in this release have been uploaded with provenance metadata.
Attestation for wadler_lindig_parts-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 Nov 6, 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.