Skip to content

Commit

Permalink
doc/excluding.rst: Use 'literal strings' for regexes in TOML
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlewis committed Jan 21, 2025
1 parent c6cd6d8 commit a117d88
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions doc/excluding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ For example, here's a list of exclusions I've used:
toml=r"""
[tool.coverage.report]
exclude_also = [
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
'def __repr__',
'if self.debug:',
'if settings.DEBUG',
'raise AssertionError',
'raise NotImplementedError',
'if 0:',
'if __name__ == .__main__.:',
'if TYPE_CHECKING:',
'class .*\bProtocol\):',
'@(abc\.)?abstractmethod',
]
""",
)
Expand Down Expand Up @@ -194,16 +194,16 @@ For example, here's a list of exclusions I've used:

[tool.coverage.report]
exclude_also = [
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
'def __repr__',
'if self.debug:',
'if settings.DEBUG',
'raise AssertionError',
'raise NotImplementedError',
'if 0:',
'if __name__ == .__main__.:',
'if TYPE_CHECKING:',
'class .*\bProtocol\):',
'@(abc\.)?abstractmethod',
]

.. code-tab:: ini
Expand All @@ -222,7 +222,7 @@ For example, here's a list of exclusions I've used:
class .*\bProtocol\):
@(abc\.)?abstractmethod

.. [[[end]]] (checksum: 06c7f40b1001590369df604495524f48)
.. [[[end]]] (checksum: 650b209edd27112381b5f0a8d2ee0c45)
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 @@ -270,11 +270,11 @@ Here are some examples:
[tool.coverage.report]
exclude_also = [
# 1. Exclude an except clause of a specific form:
"except ValueError:\\n\\s*assume\\(False\\)",
'except ValueError:\n\s*assume\(False\)',
# 2. Comments to turn coverage on and off:
"no cover: start(?s:.)*?no cover: stop",
'no cover: start(?s:.)*?no cover: stop',
# 3. A pragma comment that excludes an entire file:
"\\A(?s:.*# pragma: exclude file.*)\\Z",
'\A(?s:.*# pragma: exclude file.*)\Z',
]
""",
)
Expand All @@ -300,11 +300,11 @@ Here are some examples:
[tool.coverage.report]
exclude_also = [
# 1. Exclude an except clause of a specific form:
"except ValueError:\\n\\s*assume\\(False\\)",
'except ValueError:\n\s*assume\(False\)',
# 2. Comments to turn coverage on and off:
"no cover: start(?s:.)*?no cover: stop",
'no cover: start(?s:.)*?no cover: stop',
# 3. A pragma comment that excludes an entire file:
"\\A(?s:.*# pragma: exclude file.*)\\Z",
'\A(?s:.*# pragma: exclude file.*)\Z',
]

.. code-tab:: ini
Expand All @@ -319,7 +319,7 @@ Here are some examples:
; 3. A pragma comment that excludes an entire file:
\A(?s:.*# pragma: exclude file.*)\Z

.. [[[end]]] (checksum: 261daf325d747cdf05310e75db827af6)
.. [[[end]]] (checksum: c46e819ad9a1d3a8e37037a89d28cfde)
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

0 comments on commit a117d88

Please sign in to comment.