Skip to content

Commit 673b0c0

Browse files
Update documentation, changelog, and contributors
list for new `.coveragerc.toml` configuration file support.
1 parent 9839ed9 commit 673b0c0

File tree

3 files changed

+70
-4
lines changed

3 files changed

+70
-4
lines changed

CHANGES.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ upgrading your version of coverage.py.
2323
Unreleased
2424
----------
2525

26-
Nothing yet.
26+
- Feature: Added support for ``.coveragerc.toml`` configuration files. This
27+
provides a more flexible approach to manage coverage settings as many
28+
projects have switched to TOML configurations. Closes `issue 1643`_.
29+
30+
.. _issue 1643: https://github.com/nedbat/coveragepy/issues/1643
31+
.. _pull 1952: https://github.com/nedbat/coveragepy/pull/1952
2732

2833

2934
.. start-releases

CONTRIBUTORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ Nils Kattenbeck
185185
Noel O'Boyle
186186
Oleg Höfling
187187
Oleh Krehel
188+
Olena Yefymenko
188189
Olivier Grisel
189190
Ori Avtalion
190191
Pablo Carballo

doc/config.rst

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ environment variable.
3939

4040
If ``.coveragerc`` doesn't exist and another file hasn't been specified, then
4141
coverage.py will look for settings in other common configuration files, in this
42-
order: setup.cfg, tox.ini, or pyproject.toml. The first file found with
42+
order: .coveragerc.toml, setup.cfg, tox.ini, or pyproject.toml. The first file found with
4343
coverage.py settings will be used and other files won't be consulted.
4444

45-
Coverage.py will read from "pyproject.toml" if TOML support is available,
45+
Coverage.py will read from ".coveragerc.toml" and "pyproject.toml" if TOML support is available,
4646
either because you are running on Python 3.11 or later, or because you
47-
installed with the ``toml`` extra (``pip install coverage[toml]``).
47+
installed with the ``toml`` extra (``pip install coverage[toml]``). Both files
48+
use the same ``[tool.coverage]`` section structure.
4849

4950

5051
Syntax
@@ -136,6 +137,35 @@ Here's a sample configuration file, in each syntax:
136137
[html]
137138
directory = coverage_html_report
138139
""",
140+
141+
coveragerc_toml=r"""
142+
[tool.coverage.run]
143+
branch = true
144+
145+
[tool.coverage.report]
146+
# Regexes for lines to exclude from consideration
147+
exclude_also = [
148+
# Don't complain about missing debug-only code:
149+
"def __repr__",
150+
"if self\\.debug",
151+
152+
# Don't complain if tests don't hit defensive assertion code:
153+
"raise AssertionError",
154+
"raise NotImplementedError",
155+
156+
# Don't complain if non-runnable code isn't run:
157+
"if 0:",
158+
"if __name__ == .__main__.:",
159+
160+
# Don't complain about abstract methods, they aren't run:
161+
"@(abc\\.)?abstractmethod",
162+
]
163+
164+
ignore_errors = true
165+
166+
[tool.coverage.html]
167+
directory = "coverage_html_report"
168+
""",
139169
toml=r"""
140170
[tool.coverage.run]
141171
branch = true
@@ -198,6 +228,36 @@ Here's a sample configuration file, in each syntax:
198228
[html]
199229
directory = coverage_html_report
200230

231+
.. code-tab:: toml
232+
:caption: .coveragerc.toml
233+
234+
[tool.coverage.run]
235+
branch = true
236+
237+
[tool.coverage.report]
238+
# Regexes for lines to exclude from consideration
239+
exclude_also = [
240+
# Don't complain about missing debug-only code:
241+
"def __repr__",
242+
"if self\\.debug",
243+
244+
# Don't complain if tests don't hit defensive assertion code:
245+
"raise AssertionError",
246+
"raise NotImplementedError",
247+
248+
# Don't complain if non-runnable code isn't run:
249+
"if 0:",
250+
"if __name__ == .__main__.:",
251+
252+
# Don't complain about abstract methods, they aren't run:
253+
"@(abc\\.)?abstractmethod",
254+
]
255+
256+
ignore_errors = true
257+
258+
[tool.coverage.html]
259+
directory = "coverage_html_report"
260+
201261
.. code-tab:: toml
202262
:caption: pyproject.toml
203263

0 commit comments

Comments
 (0)