Skip to content

Commit

Permalink
update with instructions on how to use with pre-commit (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Jul 19, 2020
1 parent 085e2f1 commit 40f917b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,45 @@ In practice, here are the tools it's been tested with:
- mypy_ (you will need to have `__init__` files in each subdirectory)
- doctest_ (as long as you run it via pytest_ with the `--doctest-modules` flag)

Configuration
-------------

You can pass extra configurations to your tools either via the command line (as in the
examples above), or in a :code:`.nbqa.ini` file, which could look something like this:

.. code-block:: ini
[black]
line-length=96
[flake8]
max-line-length=88
ignore=E203,W503,W504
Flags from this :code:`.ini` will be passed to :code:`nbqa` as they're written.

Usage as pre-commit hook
------------------------

If you want to use :code:`nbqa` with `pre-commit`_, here's an example of what you
could add to your :code:`.pre-commit-config.yaml` file:

.. code-block::yaml
- repo: https://github.com/MarcoGorelli/nbQA-mirror-0
rev: master
hooks:
- id: nbqa
args: ['flake8']
- repo: https://github.com/MarcoGorelli/nbQA-mirror-1
rev: master
hooks:
- id: nbqa
args: ['isort']
Note that, because the repository keys need to be unique, you will need to use a
different mirror repository for each pre-commit hook you wish to use.

See Also
--------

Expand All @@ -134,3 +173,4 @@ Project template from cookiecutter_.
.. _black-nb: https://github.com/tomcatling/black-nb
.. _flake8-nb: https://flake8-nb.readthedocs.io/en/latest/readme.html
.. _here: https://nbqa.readthedocs.io/en/latest/
.. _`pre-commit`: https://pre-commit.com/
1 change: 1 addition & 0 deletions push-to-mirrors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
for i in 0 1 2 3 4 5 6 7 8 9; do git push mirror-$i master; done;

0 comments on commit 40f917b

Please sign in to comment.