Repository navigation
Conversation
Member
|
Thanks, I appreciate that you updated the changelog as well. The PR description includes things that should not be excluded. Please add those to the test to demonstrate that they are not matched. You'll also need to resolve conflicts. |
…overagepy#2185) The default exclusion regex for ``...`` function bodies expected the def signature to end with ``)``. When a formatter (e.g. Ruff) splits a long return-type annotation across multiple lines, the last line of the signature ends with ``]`` instead — for example:: def f() -> dict[ str, str ]: ... In that shape coverage.py reported the function body as a missing line instead of excluding it. Allow either ``)`` or ``]`` (and let them chain, e.g. ``])``) before the optional ``-> return-type`` and the trailing ``: ...`` so the exclusion applies regardless of how the signature is wrapped. This also keeps working: standalone ``...``, single-line ``def ...: ...`` declarations, and existing multi-line ``def`` signatures that close on a line by themselves. Adds a regression test exercising single-line, split-return, split- param-and-return, and split-param-with-inner-``Tuple[..., ...]`` shapes.
mokashang
force-pushed
the
fix/2185-multiline-return-ellipsis-exclusion
branch
from
June 19, 2026 16:08
348b209 to
62514df
Compare
Contributor
Author
|
Thanks for the review. Pushed an update:
(Re-checked the regex out of paranoia against a handful of other shapes that contain |
This was referenced Jun 21, 2026
nedbat
added a commit
that referenced
this pull request
Jun 21, 2026
Member
|
Thanks, what name should I put in the contributors list? |
Contributor
Author
|
Thank you! You can put Mengjia Shang as my name. :)
…On Sun, Jun 21, 2026 at 10:49 AM Ned Batchelder ***@***.***> wrote:
*nedbat* left a comment (coveragepy/coveragepy#2196)
<#2196 (comment)>
Thanks, what name should I put in the contributors list?
—
Reply to this email directly, view it on GitHub
<#2196?email_source=notifications&email_token=APMUMHJWRAZVIJN7RLHZCVT5BANZ5A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINZWGI3TSNJTHE42M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4762795399>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APMUMHMHOEBZDWZ2VVHWEQT5BANZ5AVCNFSNUABFKJSXA33TNF2G64TZHMYTGOBUGIYTSOJWHNEXG43VMU5TINRZGQZDGNJVHAYKC5QC>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Member
|
This is now released as part of coverage 7.14.3. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default exclusion regex for
...function bodies expects the defsignature to end with
). When a formatter (e.g. Ruff) splits a longreturn-type annotation across multiple lines, the last line of the
signature ends with
]instead — for example:With the current regex this function's body is reported as a missing
line, so coverage drops below 100% even though the body is just
....This change widens the optional def-header group so the closing
bracket can be any (non-empty) run of
]and). That lets theregex still match:
def f(): ...def f() -> int: ...): ...(existing case)]: ...(the bug)]) -> int: ...Tuple[int, ...]parameter types whose inner...should notitself trigger the rule
It does not start matching unintended things: an annotated assignment
like
x: list[int] = ...still doesn't match (no:after the]),and a regular function with a real body doesn't match either.
End-to-end reproducer from #2185:
Before the change:
example.py 3 0 2 1 80%(fail-under trips).After:
example.py 2 0 0 0 100%.Testing
ExcludeTest::test_default_ellipsis_multiline_return_typecoveringsingle-line, split-return, split-param-and-return, and inner-
Tuple[..., ...]shapes.
ExcludeTest::test_defaultand the rest ofExcludeTeststillpass (7/7).
tests/test_coverage.py tests/test_config.py tests/test_parser.py—233 passed, 7 skipped.
ruff format --checkandmypy --stricton the changed files — clean.Fixes #2185.