smart-covdefaults
A better version of asottile's covdefaults.
Install
pip install smart-covdefaults
Use
Enabling the plugin:
# .coveragerc
[run]
plugins = smart_covdefaults
Defaults
It provides following defaults:
[report]
show_missing = True
skip_covered = True
exclude_lines =
\# pragma: no cover\b
^\s*raise AssertionError\b
^\s*raise NotImplementedError\b
^\s*return NotImplemented\b
^\s*raise$
^\s*if (False|TYPE_CHECKING):
: \.\.\.(\s*#.*)?$
^ +\.\.\.$
-> ['"]?NoReturn['"]?:
if __name__ == ['"]__main__['"]:$
Conditional pragmas
Smart-covdefaults offers a handful of conditional pragmas to work with.
Version-dependent pragmas
# pragma: <=major.minor cover
# pragma: <major.minor cover
# pragma: >=major.minor cover
# pragma: >major.minor cover
# pragma: !=major.minor cover
# pragma: ==major.minor cover
Above are listed all possible version-dependent pragmas, that you can use. Lines will be excluded from coverage based on what python version tests are running on.
For example, if you have Python 3.11, then something like # pragma: >=3.12 cover will be
excluded, but something like # pragma: >=3.10 cover will not.
Platform-dependent pragmas
# pragma: TAG cover
# pragma: TAG no cover
Using these pragmas you can control coverage on different platforms.
Available tags are:
ntposixcygwindarwinlinuxmsyswin32cpythonpypy
Custom condition pragmas
It is also possible to add exclude_lines patterns that will be opted in or out
depending on some custom condition. These are specified under
[smart_covdefaults] exclude_conditional configuration option:
# .coveragerc
[smart_covdefaults]
exclude_conditional =
$if .*?HAS_PY_311.*?:^
py < "3.11"
$if .*?HAS_PY_312.*?:^
py < "3.12"
This configuration means that $if .*?HAS_PY_311.*?:^ will be included as a pattern if
py < "3.11" gives True. The condition is just a Python expression, that runs with
these globals:
os- theosmodulesys- thesysmodulepy- current python version. Could be compared to strings ("3.12") or floats (3.12)
exclude_conditional expects pairs of lines. In each pair, the first line is a pattern,
the second is a condition. There can be as many blank lines anywhere as you wish. The
indentation also does not matter, since .coveragerc parser dedents everything.
Developer
Project is being developed by @Tapeline.
Original version developed by @asottile
License
This work is licensed under Apache 2.0 license.
Metadata
Release files for smart-covdefaults 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smart_covdefaults-0.1.0.tar.gz | 10.7 kB | Without provenance | Details for smart_covdefaults-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smart_covdefaults-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for smart_covdefaults-0.1.0-py3-none-any.whl |
Total release size: 22.1 kB
Release files / smart_covdefaults-0.1.0.tar.gz
| Download URL | smart_covdefaults-0.1.0.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dac0e5188ea4cc818f47e2a29db07bc1b1014ada2f5b0a3a0f349519c7c45b5d
|
|
BLAKE2b-256 checksum How to use checksums |
e2871fd147cafcec9d42fad8da2004d6107b91bbe749c0d2e756e3eff3dfec8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Release files / smart_covdefaults-0.1.0-py3-none-any.whl
| Download URL | smart_covdefaults-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04bdf90deac4495cd84177ee877fb8cc3ba672fd902d67325d54906b00fd1279
|
|
BLAKE2b-256 checksum How to use checksums |
f4f6373974506622964a95311c12091d333f5961a58a510a58ccc6a6dd19482d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.17
|
Security for smart-covdefaults 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.