Skip to content

pydantic/strict-no-cover

Repository files navigation

strict-no-cover

Error on unnecessary pragma: no cover comments.

Utility to report # pragma: no cover comments which are unnecessary (where some of the relevant lines are actually covered).

For cases with flakey coverage or partial coverage on code, use # pragma: lax no cover which will not error if some relevant lines are covered.

Install

uv add --dev strict-no-cover

Usage

After running coverage and generating a .coverage file, run:

uv run strict-no-cover

or without installing it explicitly, run:

uvx strict-no-cover

You'll want to modify pyproject.toml to include the following:

[tool.coverage.report]
exclude_lines = [
    # `# pragma: no cover` is standard marker for code that's not covered, this will error if code is covered
    'pragma: no cover',
    # use `# pragma: lax no cover` if you want to ignore cases where (some of) the code is covered
    'pragma: lax no cover',
    'raise NotImplementedError',
    ...
]

About

Error on unnecessary `pragma: no cover` comments.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published