Skip to main content

pssfmt

A formatter for the Accellera Portable Test and Stimulus Standard.

$ pip install pssfmt
$ pssfmt -i src/pss/          # rewrite in place
$ pssfmt --check src/pss/     # exit 1 if anything would change

What it promises

The safety contract is the reason a team is willing to put a formatter in a pre-commit hook, and most formatters never write it down:

  • It does not change your code. Output re-lexes to the same token sequence as the input — same types, same text — and comment text is preserved character for character.
  • It converges. Formatting formatted code is a no-op.
  • It fails safe. If either property is violated for a file, pssfmt emits that file unchanged with a diagnostic. A formatter that is occasionally a no-op is survivable; one that occasionally corrupts is not.

The first two are enforced over the whole shared PSS test corpus: 92 files, of which 36 are already byte-identical to what pssfmt would write, 56 are reformatted, and none trip the fail-safe. Every one is idempotent.

What it formats

Declarations and their bodies and headers, extend blocks, import statements, field declarations, expressions, constraints, activities, template arguments and template parameters, enum declarations, function prototypes and bodies, the statements inside them, if/else, loops, match, and exec bodies — and line breaking: a call, parameter list or range that does not fit inside print_width is broken, and one you wrapped yourself is joined and re-broken from its content.

Everything else is reproduced exactly as you wrote it. That is the design rather than a stage of it: a construct with no rule falls back to the formatter that changes nothing, so an incomplete rule set cannot corrupt a file, and adding a rule cannot make an unrelated construct worse. docs/status.rst lists what is left and why each one is waiting on a decision rather than on code.

The canonical style is measured, not preferred — each rule is derived from counts over that corpus, and docs/style.rst shows the count behind each one.

Escape hatches

// pssfmt off
bit[8]   addr;      // hand-aligned, and staying that way
bit[32]  data;
// pssfmt on

Plus // pssfmt ignore for a single construct and a .pssfmtignore file for whole paths. A formatter without an off-switch is not adopted in a codebase with hand-aligned register tables, and PSS codebases have those.

Documentation

docs/ — built with Sphinx, and the build is a test rather than a courtesy.

  • Using it — quickstart, the CLI, configuration, the style and its measurements, and project status
  • Developing it — the pipeline architecture and the layout-engine reference

The layout engine (src/pssfmt/layout/) is a Wadler-style pretty printer: the Layout IR, break propagation, fits/best line breaking, greedy Fill, and a post-layout column alignment pass. It imports nothing — not pssfmt, not pssparser — and a test enforces that rather than a convention, which is what let it be built before the PSS front end existed and keeps it extractable.

Building from source

$ ivpm update                                   # resolves the dev dependency set
$ ./packages/python/bin/pip install -e . --no-deps
$ ./packages/python/bin/python -m pytest
$ make -C docs html

ivpm installs the dependencies into packages/python; the editable install is what puts pssfmt itself on the path.

Metadata

Release files for pssfmt 0.5.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 pssfmt 0.5.1
File Size Uploaded Provenance Actions
pssfmt-0.5.1.tar.gz 334.8 kB Without provenance Details for pssfmt-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pssfmt 0.5.1
File Interpreter ABI Platform Actions
pssfmt-0.5.1-py3-none-any.whl Python 3 none any Details for pssfmt-0.5.1-py3-none-any.whl

Total release size: 552.5 kB

Release files / pssfmt-0.5.1.tar.gz

Download URL pssfmt-0.5.1.tar.gz
Size 334.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b69eb32d1f0f185fe4d7e18c4c1d27a151d6ae29750535a927d6f33e51812846
BLAKE2b-256 checksum
How to use checksums
e5b3e6ab09237537a7541b4681f51c1f8d616e6445f85373ca12c233a57fbb36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / pssfmt-0.5.1-py3-none-any.whl

Download URL pssfmt-0.5.1-py3-none-any.whl
Size 217.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ccc74f4811fd34817cc6a86f136dcc0107af88198f6727490708bf7f4d87b199
BLAKE2b-256 checksum
How to use checksums
d8e7a9518fce7ba17ffbc5fa71f6430c86ccf253e26402e424be7b6f37333c77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for pssfmt 0.5.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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