A better version of asottile's covdefaults.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smart_covdefaults-0.1.0.tar.gz.
File metadata
- Download URL: smart_covdefaults-0.1.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dac0e5188ea4cc818f47e2a29db07bc1b1014ada2f5b0a3a0f349519c7c45b5d
|
|
| MD5 |
453453a7907313ae2f130e77a41d9d27
|
|
| BLAKE2b-256 |
e2871fd147cafcec9d42fad8da2004d6107b91bbe749c0d2e756e3eff3dfec8b
|
File details
Details for the file smart_covdefaults-0.1.0-py3-none-any.whl.
File metadata
- Download URL: smart_covdefaults-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04bdf90deac4495cd84177ee877fb8cc3ba672fd902d67325d54906b00fd1279
|
|
| MD5 |
64ec4697acb1cb718ebfe490db548585
|
|
| BLAKE2b-256 |
f4f6373974506622964a95311c12091d333f5961a58a510a58ccc6a6dd19482d
|