summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2018-11-21 13:40:01 -0800
committerAnthony Sottile <asottile@umich.edu>2018-11-21 13:40:48 -0800
commitef5ef0d9bf601694c2f91f5fe610c69a5a98648d (patch)
treecab9da0695953a30ddf4eb93c23804de6020a47c
parentb3f205a936c8e7d3e3866b417f44872f8bf4ad2c (diff)
downloadflake8-pre_commit_config.tar.gz
Add https://pre-commit.com metadatapre_commit_config
-rw-r--r--.pre-commit-hooks.yaml6
-rw-r--r--docs/source/user/using-hooks.rst49
2 files changed, 55 insertions, 0 deletions
diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml
new file mode 100644
index 0000000..ef8015e
--- /dev/null
+++ b/.pre-commit-hooks.yaml
@@ -0,0 +1,6 @@
+- id: flake8
+ name: flake8
+ description: '`flake8` is a command-line utility for enforcing style consistency across Python projects.'
+ entry: flake8
+ language: python
+ types: [python]
diff --git a/docs/source/user/using-hooks.rst b/docs/source/user/using-hooks.rst
index 05b1ec6..f4dcd81 100644
--- a/docs/source/user/using-hooks.rst
+++ b/docs/source/user/using-hooks.rst
@@ -2,6 +2,51 @@
Using Version Control Hooks
=============================
+Usage with the `pre-commit`_ git hooks framework
+================================================
+
+|Flake8| can be included as a hook for `pre-commit`_. The easiest way to get
+started is to add this configuration to your ``.pre-commit-config.yaml``:
+
+.. code-block:: yaml
+
+ - repo: https://gitlab.com/pycqa/flake8
+ rev: '' # pick a git hash / tag to point to
+ hooks:
+ - id: flake8
+
+See the `pre-commit docs`_ for how to customize this configuration.
+
+Checked-in python files will be passed as positional arguments. ``flake8``
+will always lint explicitly passed arguments (:option:`flake8 --exclude` has
+no effect). Instead use ``pre-commit``'s ``exclude: ...`` regex to exclude
+files. ``pre-commit`` won't ever pass untracked files to ``flake8`` so
+excluding ``.git`` / ``.tox`` / etc. is unnecesary.
+
+.. code-block:: yaml
+
+ - id: flake8
+ exclude: ^testing/(data|examples)/
+
+``pre-commit`` creates an isolated environment for hooks. To use ``flake8``
+plugins, use the ``additional_dependencies`` setting.
+
+.. code-block:: yaml
+
+ - id: flake8
+ additional_dependencies: [flake8-docstrings]
+
+
+Built-in Hook Integration
+=========================
+
+.. note::
+
+ It is strongly suggested to use |Flake8| via `pre-commit`_ over the
+ built-in hook mechanisms. ``pre-commit`` smooths out many of the rough
+ edges of ``git`` and is much more battle-tested than the |Flake8|
+ hook impementation.
+
|Flake8| can be integrated into your development workflow in many ways. A
default installation of |Flake8| can install pre-commit hooks for both
`Git`_ and `Mercurial`_. To install a built-in hook, you can use the
@@ -63,6 +108,10 @@ This is to support users who often find themselves doing things like:
first.
+.. _pre-commit:
+ https://pre-commit.com/
+.. _pre-commit docs:
+ https://pre-commit.com/#pre-commit-configyaml---hooks
.. _Git:
https://git-scm.com/
.. _Mercurial: