⚕ pystasis

PyPI version

pystasis is a tool to help you catch breaking changes in your Python projects. It does this by comparing AST (abstract-syntax tree) changes between commits in git repositories.


You can install pystasis with the following command:
pip install pystasis

Basic Usage

By default, pystasis will compare the current staged changes against HEAD. Say for example that we have the following class in our project:
class User:
    id: uuid
    name: str
    relatives: List[User]
This is a typical User class, which maps a name to a list of family members. Now let's imagine that we would like to track any relations the user has (friends, acquaintances) rather than just family members. We can just rename the field as such:
class User:
    id: uuid
    name: str
    relativesrelations: List[User]
However, this is a breaking change, and if we maintain API endpoints we cannot guarantee that downstream applications will not break. pystasis can catch this:
$ pystasis
WARNING - relatives has been renamed or removed in User (user.py)

Usage as a pre-commit hook

You can use pystasis as a git hook by adding the following to your .pre-commit-config.yaml file:
- repo: https://git.sr.ht/~regan-koopmans/pystasis
  rev: 5888c267
  - id: pystasis

Future work

pystasis is currently in pre-alpha. The following is not supported, but is intended for the final feature list: