Skip to main content

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 differences in the public API 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.dump will record the public API of mymod in a reloadable format.

  • To print the API of mymod in 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 mymod between 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 mymod versions 1.0 and 2.0, an additional positional argument b had been added to the __init__ method of the class mymod.myclass.

    $ py-api-dumper diff -o mymod.diff ...
    

    This will write out the API differences to mymod.diff in JSON format:

    • the paths to the dumps of the old and new APIs, e.g. mymod-old.dump vs. mymod-new.dump;
    • the version of mymod at the old and new API dumps, e.g. mymod 1.0 vs. 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 b argument in the above example).
  • To filter out undesired entries from API dumps before comparison:

    $ py-api-dumper diff mymod-old.dump mymod-new.dump -i <filter>
    

    Given the following API:

    MODULE : mymod
        CLASS : myclass
            FUNCTION : __init__ : no-return-type
                REQUIRED : 0 : x : int
    

    the following filters would ignore the given entries:

    <filter> Ignore entries
    MODULE All modules
    MODULE:mymod All modules named mymod
    CLASS All classes
    CLASS:myclass All classes named myclass
    MODULE:mymod;CLASS All classes in modules named mymod
    MODULE:mymod;CLASS:myclass Class myclass in module mymod
    FUNCTION:__init__ All functions named __init__
    CLASS;FUNCTION:__init__ All functioned named __init__ in classes

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 mymod in text format:

    dump.print_as_text()
    
  • To compare the API of mymod between different versions:

    diff = APIDiff.from_files("mymod-old.dump", "mymod-new.dump")
    diff.print_as_text()
    diff.save_as_json("mymod.diff")
    
  • To filter out undesired entries from API dumps before comparison:

    filter = APIFilter(("CLASS", "myclass"))   # OR: APIFilter.from_str("CLASS:myclass")
    diff = APIDiff.from_files("mymod-old.dump", "mymod-new.dump", filter)
    

Metadata

Release files for py-api-dumper 4.2.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 py-api-dumper 4.2.1
File Size Uploaded Provenance Actions
py_api_dumper-4.2.1.tar.gz 18.6 kB Without provenance Details for py_api_dumper-4.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-api-dumper 4.2.1
File Interpreter ABI Platform Actions
py_api_dumper-4.2.1-py3-none-any.whl Python 3 none any Details for py_api_dumper-4.2.1-py3-none-any.whl

Total release size: 31.7 kB

Release files / py_api_dumper-4.2.1.tar.gz

Download URL py_api_dumper-4.2.1.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4616b114958af35d638cc4d70b8b8a79a612c40884c92046f21d428d8da8ba36
BLAKE2b-256 checksum
How to use checksums
f2eb2441dedf716ce7eac9dd6d9c78c0cd956592b7ce4de4c2203d630bf30996
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / py_api_dumper-4.2.1-py3-none-any.whl

Download URL py_api_dumper-4.2.1-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c969226bfd5680280601f0f090e7c463cc1d3de24df8b6e6909cf77beae9e937
BLAKE2b-256 checksum
How to use checksums
8fd29cfdb11afbc7aa7c396ccecac9eb5913e25d2600107319aeb5e6f6b17117
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for py-api-dumper 4.2.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