api-parity-py
Python plugin for the api-parity project. Produces JSON envelopes that the api-parity differ consumes.
See the project README for the full cross-language story (Python ↔ Rust, four directions).
Install
pip install api-parity-py
Modes
How entries get produced, chosen with --mode:
- Walker — introspects a package's public API via
inspect.getmembersand emits one entry per class / method / property / function. Works on both kinds of envelope. - Annotation — collects decorators (
@parity,@parity_impl,@parity_ref) attached to your own code at import time. Works on both kinds of envelope. - AST — parses source files with
ast, without importing them.referenceonly.
Defaults: reference → walker, port → annotation.
Usage
# Walk an upstream package as a reference:
api-parity-py reference pyspark.sql.connect -o ref.json
# Annotate your own port (see below) and dump it:
api-parity-py port mylib -o port.json
# Or walk your own library and treat every public API as implemented:
api-parity-py port --mode=walker mylib -o port.json
Inventorying source you can't import
Both the walker and the annotation collector load the target. When that isn't possible — a test suite its distribution doesn't ship, or a module whose import pulls in a dependency graph that fails for reasons unrelated to the names you want — read the names off the syntax tree instead:
api-parity-py reference pyspark.sql.tests.test_catalog \
--from-source vendor/test_catalog.py -o ref.json
target is the dotted name in every mode; --from-source (which selects mode = ast) only changes where the names are read from. Point it at a file and target names that module; point it at a directory and target names that package, with the files beneath it extending the name. Either way entries key to the paths your annotations are written against, not to where the source sits in your checkout.
Only lexically-present names are visible: base classes are names rather than resolved classes, so inherited members stay attributed to the class that declares them; import-time construction is invisible; and kind follows decorator spelling. Prefer the walker whenever the target imports cleanly.
Annotating a Python port
from api_parity_py import parity, parity_impl, Status
@parity_impl(path="pyspark.sql.session.SparkSession", status=Status.IMPLEMENTED)
class SparkSession:
@parity(path=".sql", status=Status.IMPLEMENTED, since="3.4")
def sql(self, query): ...
@parity(path=".stop", status=Status.UNIMPLEMENTED, comment="no shutdown hook yet")
def stop(self): ...
A leading . in a child path is rewritten to <parent>.<child> at decoration time. Status.UNIMPLEMENTED requires a comment.
For declarative reference inventories (rare — usually a walker is better), see @parity_ref.
End-to-end
api-parity-py reference pyspark.sql.connect -o ref.json
api-parity-py port mylib -o port.json
api-parity compare ref.json port.json
Release files for api-parity-py 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| api_parity_py-0.0.3.tar.gz | 18.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| api_parity_py-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.1 kB
Release files / api_parity_py-0.0.3.tar.gz
| Download URL | api_parity_py-0.0.3.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54565556fb9f8be3cfac91c3de466fb072ca66f81dd4cc4f24c9b32e9b67f26a
|
|
BLAKE2b-256 checksum How to use checksums |
c763acadfac504c8067a10ea21a2f7b27931a796348399ce2abd680bbef68416
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Jul 30, 2026.
Transparency logRelease files / api_parity_py-0.0.3-py3-none-any.whl
| Download URL | api_parity_py-0.0.3-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
38bb91b735227f21c6d67b496e549274f290d3b3e74f7c4e3edbfae37d27dffc
|
|
BLAKE2b-256 checksum How to use checksums |
99bc706cd98330864c8485ecc25b5bde56137a048c3e81968280f3c4062bfb35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Jul 30, 2026.
Transparency log