Skip to main content

Compares ASTs of Python files that have been changed in git

Project description

Compares ASTs of Python files that have been changed in git.

Useful for checking if formatting changes do not modify the behaviour of the source code.


Python 3.6 or newer.


$ pip install python-compare-ast


$ python-compare-ast [--git-dir <path_to_git_working_dir>]

git-dir defaults to the current directory.

Example output:

$ git clone
$ python-compare-ast --git-dir click
Analysing /absolute/path/to/click/.git
Repo is clean, comparing changes in latest commit (dfb842d95a7c146d8fe8140c8100065410d95c4d).
warning: AST does not match for src/click/
warning: AST does not match for tests/
Found 2 AST differences.

If the git working directory is clean, the files changed in latest commit will be analysed. If the git working directory is dirty, the dirty files will will analysed. If no changed files has a different AST then before, python-compare-ast will exit with status code 0. However, if there are changes to the AST the exit code will be 1.

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

python-compare-ast-1.0.0.tar.gz (5.9 kB view hashes)

Uploaded source

Built Distribution

python_compare_ast-1.0.0-py3-none-any.whl (6.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page