Random assorted pre-commit hooks.
Put this in the repos
section of your .pre-commit-config.yaml
file:
- repo: https://github.com/MarcoGorelli/madforhooks
rev: 0.4.1
hooks:
- id: conda-env-sorter
- id: no-print-statements
- id: check-execution-order
- id: check-test-naming
Or, from the commandline:
pip install madforhooks
python -m madforhooks.check_execution_order file1.ipynb file2.ipynb file3.ipynb
Example of how to run check-test-naming
on your test directory:
git ls-files | xargs python -m madforhooks.check_test_naming
Sort the dependencies in your conda environment file(s).
Raise if print statements are found (unless they have file=
).
Raise if notebook cells were executed out-of-order. Use --strict
to ensure
strict monotonicity.
Check that test names start with test
. This is useful for finding
tests which are meant to be running in CI, but which don't because they
are misnamed.
If there are any false positives, you prevent this tool from flagging them
by adding a # not a test
comment one the line where the function/class is
defined.