Python API dumping and comparison tool
Project description
Python API dumping and comparison tool
Dumps the public API of a Python module and its members to a file, which can then be used to show the differences in the public between two dumps, e.g. of different versions of the same module.
Command-line interface
$ py-api-dumper --help
-
To dump the public API of a module
mymod:$ py-api-dumper dump -o mymod1.dump mymod
mymod1.dumpwill record the public API ofmymodin a reloadable format. -
To print the API of
mymodin text format:$ py-api-dumper dump mymod MODULE : mymod CLASS : myclass FUNCTION : __init__ : no-return-type REQUIRED : 0 : x : int ...
The text format is a tree of entries of each nested class, class method, function, member variable, etc. in the public API.
-
To compare the API of
mymodbetween different versions:$ py-api-dumper diff mymod-old.dump mymod-new.dump --- mymod-old.dump mymod=1.0 +++ mymod-new.dump mymod=2.0 +MODULE : mymod + CLASS : myclass + FUNCTION : __init__ : no-return-type + REQUIRED : 1 : b : no-type
The above output shows the expected output if, between
mymodversions 1.0 and 2.0, an additional positional argumentbhad been added to the__init__method of the classmymod.myclass.$ py-api-dumper diff -o mymod.diff ...
This will write out the API differences to
mymod.diffin JSON format:- the paths to the dumps of the old and new APIs, e.g.
mymod-old.dumpvs.mymod-new.dump; - the version of
mymodat the old and new API dumps, e.g. mymod1.0vs.2.0; - API entries which have been removed, i.e. present in the old API but not in the new API (e.g. none in the above example);
- API entries which have been added, i.e. present in the new API but not in
the old API (e.g. the
bargument in the above example).
- the paths to the dumps of the old and new APIs, e.g.
Python interface
from py_api_dumper import APIDump, APIDiff
-
To dump the public API of a module
mymod:import mymod dump = APIDump.from_modules(mymod) # OR: APIDump.from_modules("mymod") dump.save_to_file("mymod.dump")
-
To print the API of
mymodin text format:dump.print_as_text()
-
To compare the API of
mymodbetween different versions:diff = APIDiff.from_files("mymod-old.dump", "mymod-new.dump") diff.print_as_text() with open("mymod.diff", as file): diff.print_as_json(file)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_api_dumper-2.0.tar.gz.
File metadata
- Download URL: py_api_dumper-2.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cf1e62404628bfbd5cf8a9433dcca71d358fd84f4c9e00f8cf9ade4ae729f1b
|
|
| MD5 |
9f35c9c982e9e91912a3dd68e9f24173
|
|
| BLAKE2b-256 |
bae6d8309d9168ceccb2478316c5e5dd8110fb733e2654f1ccf7a118bea17328
|
File details
Details for the file py_api_dumper-2.0-py3-none-any.whl.
File metadata
- Download URL: py_api_dumper-2.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db75193a91c6bc0e4ddae436a0ca5684587db175183e421b4197397df0e22156
|
|
| MD5 |
f9a175fe0ad0fdff0b62da209d359a2e
|
|
| BLAKE2b-256 |
a7a50db4e05f353eec561db8f89169eef68b0150e5b0d372ed422830dff4b5d6
|