Skip to content

Commit 87bfa42

Browse files
committed
docs: Document how to install pre-commit hook
1 parent be9ed9c commit 87bfa42

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

docs/contributing.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ More details on using ``unittest`` are `here
4545
Code quality checks
4646
^^^^^^^^^^^^^^^^^^^
4747

48+
tl;dr: Run ``pre-commit install --overwrite`` to perform checks when committing, and
49+
``./scripts/test`` to run the tests.
50+
4851
PySTAC uses
4952

5053
- `black <https://github.com/psf/black>`_ for Python code formatting
@@ -53,13 +56,18 @@ PySTAC uses
5356
- `flake8 <http://flake8.pycqa.org/en/latest/>`_ for Python style checks
5457
- `mypy <http://www.mypy-lang.org/>`_ for Python type annotation checks
5558

56-
To run all of these:
57-
58-
.. code-block:: bash
59+
Run all of these with ``pre-commit run --all-files`` or a single one using
60+
``pre-commit run --all-files ID``, where ``ID`` is one of the command names above. For
61+
example, to format all the Python code, run ``pre-commit run --all-files black``.
5962

60-
> pre-commit run --all-files
63+
You can also install a Git pre-commit hook which will run the relevant linters and
64+
formatters on any staged code when committing. This will be much faster than running on
65+
all files, which is usually[#]_ only required when changing the pre-commit version or
66+
configuration. Once installed you can bypass this check by adding the ``--no-verify``
67+
flag to Git commit commands, as in ``git commit --no-verify``.
6168

62-
You can also run ``./scripts/test`` to run the tests.
69+
.. [#] In rare cases changes to one file might invalidate an unchanged file, such as
70+
when modifying the return type of a function used in another file.
6371
6472
CHANGELOG
6573
^^^^^^^^^

0 commit comments

Comments
 (0)