Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure pytest with [tool.coverage.report] exclusions #154

Closed
nathanjmcdougall opened this issue Jan 9, 2025 · 1 comment
Closed

Configure pytest with [tool.coverage.report] exclusions #154

nathanjmcdougall opened this issue Jan 9, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@nathanjmcdougall
Copy link
Owner

Motivation
Some lines of code we expect to be impossible to reach, e.g. ones with assert_never. But code coverage will degrade because of these lines. You can configure coverage to ignore then with [tool.coverage.report].exclude_also. For example:

[tool.coverage.report]
exclude_also  = [
  "if TYPE_CHECKING:",
  "raise AssertionError",
  "raise NotImplementedError",
  "assert_never(.*)",
  "class .*\\bProtocol\\):",
  "@(abc\\.)?abstractmethod",
]

Summary of desired enhancement
Add logic to the usethis pytest command which automatically adds sensible excludes.

@nathanjmcdougall nathanjmcdougall added the enhancement New feature or request label Jan 9, 2025
@nathanjmcdougall nathanjmcdougall self-assigned this Jan 9, 2025
@nathanjmcdougall
Copy link
Owner Author

Duplicate of #159

@nathanjmcdougall nathanjmcdougall marked this as a duplicate of #159 Jan 11, 2025
@nathanjmcdougall nathanjmcdougall closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant