Skip to content

PyMC3 Python Code Style

Marco Gorelli edited this page Nov 9, 2020 · 8 revisions

Python Code Style

Some code-quality checks are performed during continuous integration. The easiest way to check that they pass locally, before submitting your pull request, is by using pre-commit.

Steps to get set up are (run these within your virtual environment):

  1. install:

    pip install pre-commit
  2. enable:

    pre-commit install

Now, whenever you stage some file, then when you run git commit -m "<some descriptive message>", pre-commit will run the checks defined in .pre-commit-config.yaml and will block your commit if any of them fail. If any hook fails, you should fix it (if necessary), run git add <files> again, and then re-run git commit -m "<some descriptive message>".

You can skip pre-commit using --no-verify, e.g.

git commit -m "wip lol" --no-verify

To skip one particular hook, you can set the SKIP environment variable. E.g. (on Linux):

SKIP=pyupgrade git commit -m "<descriptive message>"

You can manually run all pre-commit hooks on all files with

pre-commit run --all-files

or, if you just want to manually run it on a subset of files,

pre-commit run --files <file_1> <file_2> ... <file_n>