Skip to content

Don't exclude a statement because of ... inside a string - #2329

Open
Kayvan-Zahiri wants to merge 1 commit into
coveragepy:mainfrom
Kayvan-Zahiri:fix/ellipsis-in-string-2112
Open

Kayvan-Zahiri wants to merge 1 commit into
coveragepy:mainfrom
Kayvan-Zahiri:fix/ellipsis-in-string-2112

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

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.

Exclusion matches that sit entirely inside a string literal (including f-string and t-string text) are now ignored. A real ... statement and a stub such as def stub(): ... are still excluded.

Test plan

  • tests/test_coverage.py::ExcludeTest::test_ellipsis_inside_string_is_not_excluded failed 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]).
  • The same test passes after the change.
  • ExcludeTest and tests/test_parser.py: 104 passed, 1 skipped.

Made with Cursor

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]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default ... exclusion can exclude things by accident

1 participant