Skip to content
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Version 7.10.7 — 2025-09-21
LCOV reports could take far too long due to some quadratic behavior when
creating the function and class index pages. This is now fixed, closing
`issue 2048`_. Thanks to Daniel Diniz for help diagnosing the problem.
- New feature: coverage.py now supports :file:`.coveragerc.toml` configuration files.
These files use TOML syntax and take priority over :file:`pyproject.toml` but lower
priority than :file:`.coveragerc` files.

- Most warnings and a few errors now have links to a page in the docs
explaining the specific message. Closes `issue 1921`_.
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ Nils Kattenbeck
Noel O'Boyle
Oleg Höfling
Oleh Krehel
Olena Yefymenko
Olivier Grisel
Ori Avtalion
Pablo Carballo
Expand Down
1 change: 1 addition & 0 deletions coverage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ def config_files_to_try(config_file: bool | str) -> list[tuple[str, bool, bool]]
assert isinstance(config_file, str)
files_to_try = [
(config_file, True, specified_file),
(".coveragerc.toml", True, False),
("setup.cfg", False, False),
Comment on lines +647 to 648
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the priority of the new config properly determined in the config_files_to_try function?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

("tox.ini", False, False),
("pyproject.toml", False, False),
Expand Down
2 changes: 1 addition & 1 deletion doc/cog_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def show_configs(ini, toml):
print(".. tabs::\n")
for name, syntax, text in [
(".coveragerc", "ini", ini),
("pyproject.toml", "toml", toml),
(".coveragerc.toml or pyproject.toml", "toml", toml),
("setup.cfg or tox.ini", "ini", ini2),
]:
print(f" .. code-tab:: {syntax}")
Expand Down
10 changes: 5 additions & 5 deletions doc/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ environment variable.

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

Coverage.py will read from "pyproject.toml" if TOML support is available,
Expand Down Expand Up @@ -199,7 +199,7 @@ Here's a sample configuration file, in each syntax:
directory = coverage_html_report

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.run]
branch = true
Expand Down Expand Up @@ -257,7 +257,7 @@ Here's a sample configuration file, in each syntax:
[coverage:html]
directory = coverage_html_report

.. [[[end]]] (sum: HU1Z62mvRK)
.. [[[end]]] (sum: FvgoIIyfXR)


The specific configuration settings are described below. Many sections and
Expand Down Expand Up @@ -598,7 +598,7 @@ equivalent when combining data from different machines:
c:\myproj\src

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.paths]
source = [
Expand All @@ -616,7 +616,7 @@ equivalent when combining data from different machines:
/jenkins/build/*/src
c:\myproj\src

.. [[[end]]] (sum: oHSl8SGiMT)
.. [[[end]]] (sum: bV+PjKu+HS)


The names of the entries ("source" in this example) are ignored, you may choose
Expand Down
4 changes: 2 additions & 2 deletions doc/contexts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The ``[run] dynamic_context`` setting has only one option now. Set it to
dynamic_context = test_function

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.run]
dynamic_context = "test_function"
Expand All @@ -108,7 +108,7 @@ The ``[run] dynamic_context`` setting has only one option now. Set it to
[coverage:run]
dynamic_context = test_function

.. [[[end]]] (sum: dZTDYjHw71)
.. [[[end]]] (sum: Hn9VZdxp00)

Each test function you run will be considered a separate dynamic context, and
coverage data will be segregated for each. A test function is any function
Expand Down
12 changes: 6 additions & 6 deletions doc/excluding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ all of them by adding a regex to the exclusion list:
def __repr__

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.report]
exclude_also = [
Expand All @@ -159,7 +159,7 @@ all of them by adding a regex to the exclusion list:
exclude_also =
def __repr__

.. [[[end]]] (sum: 8+cOvxKPvv)
.. [[[end]]] (sum: QqurBI2O5i)

For example, here's a list of exclusions I've used:

Expand Down Expand Up @@ -216,7 +216,7 @@ For example, here's a list of exclusions I've used:
@(abc\.)?abstractmethod

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.report]
exclude_also = [
Expand Down Expand Up @@ -248,7 +248,7 @@ For example, here's a list of exclusions I've used:
class .*\bProtocol\):
@(abc\.)?abstractmethod

.. [[[end]]] (sum: ZQsgnt0nES)
.. [[[end]]] (sum: z5MhXz2dFm)

The :ref:`config_report_exclude_also` option adds regexes to the built-in
default list so that you can add your own exclusions. The older
Expand Down Expand Up @@ -319,7 +319,7 @@ Here are some examples:
\A(?s:.*# pragma: exclude file.*)\Z

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.report]
exclude_also = [
Expand All @@ -343,7 +343,7 @@ Here are some examples:
; 3. A pragma comment that excludes an entire file:
\A(?s:.*# pragma: exclude file.*)\Z

.. [[[end]]] (sum: xG6Bmtmh06)
.. [[[end]]] (sum: 3EupeurnDP)

The first regex matches a specific except line followed by a specific function
call. Both lines must be present for the exclusion to take effect. Note that
Expand Down
4 changes: 2 additions & 2 deletions doc/messages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ file:
disable_warnings = no-data-collected

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.run]
disable_warnings = ["no-data-collected"]
Expand All @@ -198,4 +198,4 @@ file:
[coverage:run]
disable_warnings = no-data-collected

.. [[[end]]] (sum: SJKFvPoXO2)
.. [[[end]]] (sum: lZkA6+wMrL)
8 changes: 4 additions & 4 deletions doc/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ a coverage.py plug-in called ``something.plugin``.
something.plugin

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.run]
plugins = [ "something.plugin" ]
Expand All @@ -84,7 +84,7 @@ a coverage.py plug-in called ``something.plugin``.
plugins =
something.plugin

.. [[[end]]] (sum: boZjI9S8MZ)
.. [[[end]]] (sum: 7iXDMHhoLG)

#. If the plug-in needs its own configuration, you can add those settings in
the .coveragerc file in a section named for the plug-in:
Expand Down Expand Up @@ -114,7 +114,7 @@ a coverage.py plug-in called ``something.plugin``.
option2 = abc.foo

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.something.plugin]
option1 = true
Expand All @@ -127,7 +127,7 @@ a coverage.py plug-in called ``something.plugin``.
option1 = True
option2 = abc.foo

.. [[[end]]] (sum: tpARXb5/bH)
.. [[[end]]] (sum: QeURQmX7B1)

Check the documentation for the plug-in for details on the options it takes.

Expand Down
4 changes: 2 additions & 2 deletions doc/source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ current directory:
utils/tirefire.py

.. code-tab:: toml
:caption: pyproject.toml
:caption: .coveragerc.toml or pyproject.toml

[tool.coverage.run]
omit = [
Expand All @@ -139,7 +139,7 @@ current directory:
# omit this single file
utils/tirefire.py

.. [[[end]]] (sum: hK0nQ8wMeg)
.. [[[end]]] (sum: 6pS//9tCe4)

The ``source``, ``include``, and ``omit`` values all work together to determine
the source that will be measured.
Expand Down
Loading
Loading