@@ -161,7 +161,8 @@ Using a config file
161
161
162
162
Command line options can also be specified in a config file.
163
163
164
- When running ``codespell ``, it will check in the current directory for a file
164
+ When running ``codespell ``, it will check in the current directory for an
165
+ `INI file <https://en.wikipedia.org/wiki/INI_file >`_
165
166
named ``setup.cfg `` or ``.codespellrc `` (or a file specified via ``--config ``),
166
167
containing an entry named ``[codespell] ``. Each command line argument can
167
168
be specified in this file (without the preceding dashes), for example:
@@ -173,32 +174,16 @@ be specified in this file (without the preceding dashes), for example:
173
174
count =
174
175
quiet-level = 3
175
176
176
- The ``.codespellrc `` file is an `INI file <https://en.wikipedia.org/wiki/INI_file >`_,
177
- which is read using Python's
178
- `configparser <https://docs.python.org/3/library/configparser.html#supported-ini-file-structure >`_.
179
- For example, comments are possible using ``; `` or ``# `` as the first character.
180
-
181
- Values in an INI file entry cannot start with a ``- `` character, so if you need to do this,
182
- structure your entries like this:
183
-
184
- .. code-block :: ini
185
-
186
- [codespell]
187
- dictionary = mydict,-
188
- ignore-words = bar,-foo
189
-
190
- instead of these invalid entries:
191
-
192
- .. code-block :: ini
193
-
194
- [codespell]
195
- dictionary = -,mydict
196
- ignore-words = -foo,bar
177
+ Python's
178
+ `configparser <https://docs.python.org/3/library/configparser.html#supported-ini-file-structure >`_
179
+ module defines the exact format of INI config files. For example,
180
+ comments are possible using ``; `` or ``# `` as the first character.
197
181
198
182
Codespell will also check in the current directory for a ``pyproject.toml ``
199
- (or a path can be specified via ``--toml <filename> ``) file, and the
200
- ``[tool.codespell] `` entry will be used, but only if the tomli _ package
201
- is installed for versions of Python prior to 3.11. For example:
183
+ file (or a file specified via ``--toml ``), and the ``[tool.codespell] ``
184
+ entry will be used. For versions of Python prior to 3.11, this requires
185
+ the tomli _ package. For example, here is the TOML equivalent of the
186
+ previous config file:
202
187
203
188
.. code-block :: toml
204
189
@@ -207,25 +192,40 @@ is installed for versions of Python prior to 3.11. For example:
207
192
count = true
208
193
quiet-level = 3
209
194
210
- These are both equivalent to running:
195
+ The above INI and TOML files are equivalent to running:
211
196
212
197
.. code-block :: sh
213
198
214
- codespell --quiet-level 3 --count -- skip " *.po,*.ts,./src/3rdParty,./src/Test"
199
+ codespell --skip " *.po,*.ts,./src/3rdParty,./src/Test" --count --quiet-level 3
215
200
216
201
If several config files are present, they are read in the following order:
217
202
218
- #. ``pyproject.toml `` (only if the ``tomli `` library is available)
203
+ #. ``pyproject.toml `` (only if the ``tomli `` library is available for Python < 3.11 )
219
204
#. ``setup.cfg ``
220
205
#. ``.codespellrc ``
221
206
#. any additional file supplied via ``--config ``
222
207
223
208
If a codespell configuration is supplied in several of these files,
224
209
the configuration from the most recently read file overwrites previously
225
- specified configurations.
210
+ specified configurations. Any options specified in the command line will
211
+ *override * options from the config files.
226
212
227
- Any options specified in the command line will *override * options from the
228
- config files.
213
+ Values in a config file entry cannot start with a ``- `` character, so if
214
+ you need to do this, structure your entries like this:
215
+
216
+ .. code-block :: ini
217
+
218
+ [codespell]
219
+ dictionary = mydict,-
220
+ ignore-words = bar,-foo
221
+
222
+ instead of these invalid entries:
223
+
224
+ .. code-block :: ini
225
+
226
+ [codespell]
227
+ dictionary = -,mydict
228
+ ignore-words = -foo,bar
229
229
230
230
.. _tomli : https://pypi.org/project/tomli/
231
231
0 commit comments