You can easily use
nbqa as a pre-commit hook.
Here’s an example of what you could include in your
repos: - repo: https://github.com/nbQA-dev/nbQA rev: 1.3.1 hooks: - id: nbqa-black additional_dependencies: [black==20.8b1] - id: nbqa-pyupgrade additional_dependencies: [pyupgrade==2.7.3] - id: nbqa-isort additional_dependencies: [isort==5.6.4]
For best reproducibility, you should pin your dependencies (as above). Running
pre-commit autoupdate will update your hooks’ versions, but
versions of additional dependencies need to updated manually.
See .pre-commit-hooks.yaml for all available built-in hooks.
If you have your own custom tool (e.g.
customtool) for which we currently don’t have a built-in hook, you can define your own one with:
- repo: https://github.com/nbQA-dev/nbQA rev: 1.3.1 hooks: - id: nbqa entry: nbqa customtool name: nbqa-customtool alias: nbqa-customtool additional_dependencies: [customtool==<version number>]
Temporarily disable hooks
Although not recommended, it is still possible to temporarily disable all checks
git commit --no-verify, or just specific ones using the
environment variable. For example, on a Unix-like operating system:
SKIP=nbqa-black git commit -m "foo"
For more details, please check out the pre-commit documentation.