@@ -36,83 +36,7 @@ plugins, use the ``additional_dependencies`` setting.
36
36
- id : flake8
37
37
additional_dependencies : [flake8-docstrings]
38
38
39
-
40
- Built-in Hook Integration
41
- =========================
42
-
43
- .. note ::
44
-
45
- It is strongly suggested to use |Flake8 | via `pre-commit `_ over the
46
- built-in hook mechanisms. ``pre-commit `` smooths out many of the rough
47
- edges of ``git `` and is much more battle-tested than the |Flake8 |
48
- hook implementation.
49
-
50
- |Flake8 | can be integrated into your development workflow in many ways. A
51
- default installation of |Flake8 | can install pre-commit hooks for both
52
- `Git `_ and `Mercurial `_. To install a built-in hook, you can use the
53
- :option: `flake8 --install-hook ` command-line option. For example, you can
54
- install a git pre-commit hook by running:
55
-
56
- .. prompt :: bash
57
-
58
- flake8 --install-hook git
59
-
60
- This will install the pre-commit hook into ``.git/hooks/ ``. Alternatively,
61
- you can install the mercurial commit hook by running
62
-
63
- .. prompt :: bash
64
-
65
- flake8 --install-hook mercurial
66
-
67
-
68
- Preventing Commits
69
- ==================
70
-
71
- By default, |Flake8 | does not prevent you from creating a commit with these
72
- hooks. Both hooks can be configured to be strict easily.
73
-
74
- Both our Git and Mercurial hooks check for the presence of ``flake8.strict ``
75
- in each VCS' config. For example, you might configure this like so:
76
-
77
- .. prompt :: bash
78
-
79
- git config --bool flake8.strict true
80
- hg config flake8.strict true
81
-
82
-
83
- Checking All Modified Files Currently Tracked
84
- =============================================
85
-
86
- .. note ::
87
-
88
- Mercurial does not have the concept of an index or "stage" as best as I
89
- understand.
90
-
91
- |Flake8 | aims to make smart choices that keep things fast for users where
92
- possible. As a result, the |Flake8 | Git pre-commit will default to only
93
- checking files that have been staged (i.e., added to the index). If, however,
94
- you are keen to be lazy and not independently add files to your git index, you
95
- can set ``flake8.lazy `` to ``true `` (similar to how you would set
96
- ``flake8.strict `` above) and this will check all tracked files.
97
-
98
- This is to support users who often find themselves doing things like:
99
-
100
- .. prompt :: bash
101
-
102
- git commit -a
103
-
104
- .. note ::
105
-
106
- If you have files you have not yet added to the index, |Flake8 | will not
107
- see these and will not check them for you. You must ``git-add `` them
108
- first.
109
-
110
-
111
39
.. _pre-commit :
112
40
https://pre-commit.com/
113
41
.. _pre-commit docs :
114
42
https://pre-commit.com/#pre-commit-configyaml---hooks
115
- .. _Git :
116
- https://git-scm.com/
117
- .. _Mercurial :
118
- https://www.mercurial-scm.org/
0 commit comments