Skip to main content

Tool for checking for breaking changes in Python APIs

Project description

About pyapi-checker

Tool for checking for and acknowledging Python API breaking changes. Inspired by gradle-revapi and built with the aexpy API explorer.

Usage

Once you've installed pyapi-checker in an environment in your project you can interface with the pyapi CLI.

pyapi analyze is the command for checking for API breaks in your project which will produce output like this if you have 2 API breaks for example, and also exit with exit code 1:

Python API breaks found in my-lib:
AddRequiredParameter: Add PositionalOrKeyword parameter (functions.bin.parse.parse): new_param.
MoveParameter: Move parameter (functions.bin.parse.parse): handle_errors: 3 -> 4.

So you would want to include pyapi analyze in your CI process to require developers to acknowledge API breaks when creating PRs on a library.

Accepting Breaks

You can accept a single break via:

pyapi acceptBreak "{break code}" "{justification why this is ok}"

Or accept all breaks via:

pyapi acceptAllBreaks "{justification why this is ok}"

Accepted breaks will populate in the .palantir/pyapi.yml file looking like this:

acceptedBreaks:
  version:
    projectName:
    - code: 'break code'
      justification: justification

Version overrides

Sometimes the previous release will have a successfully applied git tag but a failed publish build. In this case pyapi-checker will fail as it cannot resolve the previous API to compare against. To resolve this, you can set a version override that will use a different version instead of the last git tag. To do so, use the

pyapi versionOverride <last-published-version>

command to use the last correctly published version instead. This will create an entry in .palantir/pyapi.yml of the following format:

versionOverrides:
  version: <last-published-version>

Configuration

Python Index

After identifying the last published version preceeding your current commit, pyapi-checker downloads the corresponding wheel for your package and version from a Python index. If you do not specify an index then pyapi-checker uses the following in order (if set):

  1. PIP_INDEX_URL
  2. UV_DEFAULT_INDEX
  3. https://pypi.org/simple

To manually set an index you can set the following configuration:

[tool.pyapi-checker]
index = "<your-index-url>"

Implementation

pyapi-checker uses aexpy to power it's API breakage detection. You can check out the list of types of API breaks that aexpy detects here.

Note: aexpy does not consider any breaks to an internal module, function, attribute, etc. a high priority breaking change and thus we will not flag these breaks to you.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyapi_checker-0.11.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyapi_checker-0.11.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file pyapi_checker-0.11.0.tar.gz.

File metadata

  • Download URL: pyapi_checker-0.11.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for pyapi_checker-0.11.0.tar.gz
Algorithm Hash digest
SHA256 04873e88d54aa5801fb9d9bfa02268f7756aa0a07a4bedca801ab6502a8fb0c2
MD5 8caa0d87ca32d63d9b6fa5cd51e8e798
BLAKE2b-256 5a04001adb8562f0990ddebcc65e5ef3572535aaa1f585464006c46c4c1a85be

See more details on using hashes here.

File details

Details for the file pyapi_checker-0.11.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyapi_checker-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b113887bda31921ea731eca6f0b7d499fc71bffb594fc6394f4abdfbfea7a80c
MD5 3c906946b9be6152a70ea9ddd443a6b4
BLAKE2b-256 89339b360f375a98c49eb62c835b5cb1d3aebc0ada67fddde8f4ea03cdcb89e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page