Skip to content

Add msg = ["'] to coverage.py exclude_also patterns#1593

Merged
nathanjmcdougall merged 3 commits into
mainfrom
copilot/ignore-msg-lines-in-coverage
Mar 27, 2026
Merged

Add msg = ["'] to coverage.py exclude_also patterns#1593
nathanjmcdougall merged 3 commits into
mainfrom
copilot/ignore-msg-lines-in-coverage

Conversation

Copilot AI commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

When EM ruff rules are enabled, raise messages must be extracted to a preceding line — conventionally msg = "..." or msg = '...' (ruff's autofix uses this variable name). These lines should be excluded from coverage like raise NotImplementedError already is. Per discussion, always exclude regardless of whether EM rules are active.

  • Added msg = ["'] to exclude_also in CoveragePyToolSpec.config_spec(), matching both single and double quote styles without requiring a closing quote (to support multi-line strings)
  • Updated project's own pyproject.toml coverage config to match
  • Updated test expectations for .coveragerc and tox.ini output formats

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

When EM ruff rules require error messages to be defined outside `raise`
statements, the convention is `msg = "..."`. These lines should be
excluded from coverage, just like `raise NotImplementedError`.

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/918aa6cc-e210-457c-86f9-0e589eea5030

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Ignore msg = "*" lines in coverage Add msg = ".*" to coverage.py exclude_also patterns Mar 27, 2026
Copilot AI requested a review from nathanjmcdougall March 27, 2026 10:14
Comment thread src/usethis/_tool/impl/spec/coverage_py.py Outdated
…thout requiring closing quote

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/71169fc6-2da1-43ac-8f35-588dbb29b078

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title Add msg = ".*" to coverage.py exclude_also patterns Add msg = ["'] to coverage.py exclude_also patterns Mar 27, 2026
Copilot AI requested a review from nathanjmcdougall March 27, 2026 10:26
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review March 27, 2026 10:36
@codecov

codecov Bot commented Mar 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Mar 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/ignore-msg-lines-in-coverage (e0939e8) with main (211b0d2)

Open in CodSpeed

@nathanjmcdougall nathanjmcdougall merged commit 643d7ac into main Mar 27, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/ignore-msg-lines-in-coverage branch March 27, 2026 11:39
@nathanjmcdougall nathanjmcdougall linked an issue Mar 30, 2026 that may be closed by this pull request
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.

Ignore msg = "*" lines in coverage

2 participants