@@ -95,20 +95,6 @@ advise that you enable merge summaries within git:
95
95
96
96
See :ref: `configure-git ` for more detail.
97
97
98
- Pre-commit hooks
99
- ----------------
100
-
101
- NiBabel uses pre-commit _ to help committers validate their changes
102
- before committing. To enable these, you can use pipx _::
103
-
104
- pipx run pre-commit install
105
-
106
- Or install and run::
107
-
108
- python -m pip install pre-commit
109
- pre-commit install
110
-
111
-
112
98
Testing
113
99
=======
114
100
@@ -139,6 +125,55 @@ full set of optional dependencies that are available for 64-bit
139
125
interpreters. If you are using 32-bit Python, replace ``-x64 `` with ``-x86 ``.
140
126
141
127
128
+ Style guide
129
+ ===========
130
+
131
+ To ensure code consistency and readability, NiBabel has adopted the following
132
+ tools:
133
+
134
+ * blue _ - An auto-formatter that aims to reduce diffs to relevant lines
135
+ * isort _ - An import sorter that groups stdlib, third-party and local imports.
136
+ * flake8 _ - A style checker that can catch (but generally not fix) common
137
+ errors in code.
138
+ * codespell _ - A spell checker targeted at source code.
139
+ * pre-commit _ - A pre-commit hook manager that runs the above and various
140
+ other checks/fixes.
141
+
142
+ While some amount of personal preference is involved in selecting and
143
+ configuring auto-formatters, their value lies in largely eliminating the
144
+ need to think or argue about style.
145
+ With pre-commit turned on, you can write in the style that works for you,
146
+ and the NiBabel style will be adopted prior to the commit.
147
+
148
+ To apply our style checks uniformly, simply run::
149
+
150
+ tox -e style,spellcheck
151
+
152
+ To fix any issues found::
153
+
154
+ tox -e style-fix
155
+ tox -e spellcheck -- -w
156
+
157
+ Occasionally, codespell has a false positive. To ignore the suggestion, add
158
+ the intended word to ``tool.codespell.ignore-words-list `` in ``pyproject.toml ``.
159
+ However, the ignore list is a blunt instrument and could cause a legitimate
160
+ misspelling to be missed. Consider choosing a word that does not trigger
161
+ codespell before adding it to the ignore list.
162
+
163
+ Pre-commit hooks
164
+ ----------------
165
+
166
+ NiBabel uses pre-commit _ to help committers validate their changes
167
+ before committing. To enable these, you can use pipx _::
168
+
169
+ pipx run pre-commit install
170
+
171
+ Or install and run::
172
+
173
+ python -m pip install pre-commit
174
+ pre-commit install
175
+
176
+
142
177
Changelog
143
178
=========
144
179
@@ -168,6 +203,9 @@ Please see `our community guidelines
168
203
<https://github.com/nipy/nibabel/blob/master/.github/CODE_OF_CONDUCT.md> `_.
169
204
Other projects call these guidelines the "code of conduct".
170
205
171
- .. _tox : https://tox.wiki
206
+ .. _blue : https://blue.readthedocs.io/
207
+ .. _codespell : https://github.com/codespell-project/codespell
208
+ .. _flake8 : https://flake8.pycqa.org/
172
209
.. _pipx : https://pypa.github.io/pipx/
173
210
.. _precommit : https://pre-commit.com/
211
+ .. _tox : https://tox.wiki/
0 commit comments