Repository navigation
Don't exclude a statement because of ... inside a string - #2329
Open
Kayvan-Zahiri wants to merge 4 commits into
Open
Kayvan-Zahiri wants to merge 4 commits into
Kayvan-Zahiri wants to merge 4 commits into
Conversation
The default ellipsis exclusion treated a line of three dots inside a multi-line string as a stub body and dropped the whole assignment. Co-authored-by: Cursor <[email protected]>
Skipping every match inside a string changed documented behavior: exclude_lines = foo still has to exclude t = "foo ...", as test_lcov.py::test_excluded_lines checks. A line with no code on it, like the YAML ... marker in coveragepy#2112, is skipped; a code line is not.
…ing-2112 # Conflicts: # CHANGES.rst
This branch has not been deployed
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.
Summary
Fixes #2112.
The default
...exclusion is meant to drop a line that is only an ellipsis, and a function whose body is only.... It also matched a line of three dots inside a multi-line string. A YAML literal that ends with...was then excluded as a whole, so the assignment never showed up in the report.An exclusion match is now ignored when its whole line sits inside a string literal (including f-string and t-string text), so a line with no code on it can't exclude the statement. A match on a line that also has code still counts, so
exclude_lines = foostill excludest = "foo is ignored", astest_lcov.py::test_excluded_linesexpects. A real...statement and a stub such asdef stub(): ...are still excluded.Test plan
tests/test_coverage.py::ExcludeTest::test_ellipsis_inside_string_is_not_excludedfailed before the change: the YAML, f-string, and bytes assignments were missing from the measured lines ([6, 11, 15, 17]instead of[1, 6, 8, 11, 12, 15, 17]).ExcludeTestandtests/test_parser.py: 104 passed, 1 skipped.Made with Cursor