Repository navigation
Commit f4b2b4d
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.
Co-authored-by: Ned Batchelder <[email protected]>
1 parent 1980ed0 commit f4b2b4d
3 files changed
Lines changed: 38 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
| 66 | + | |
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1503 | 1503 | | |
1504 | 1504 | | |
1505 | 1505 | | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
1506 | 1536 | | |
1507 | 1537 | | |
1508 | 1538 | | |
| |||
0 commit comments