covdefaults


Namecovdefaults JSON
Version 2.2.2 PyPI version JSON
download
home_pagehttps://github.com/asottile/covdefaults
SummaryA coverage plugin to provide sensible default settings
upload_time2022-12-03 17:45:55
maintainer
docs_urlNone
authorAnthony Sottile
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/asottile.covdefaults?branchName=main)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=62&branchName=main)
[![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/asottile/asottile/62/main.svg)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=62&branchName=main)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/asottile/covdefaults/main.svg)](https://results.pre-commit.ci/latest/github/asottile/covdefaults/main)

covdefaults
===========

A coverage plugin to provide sensible default settings

## installation

```bash
pip install covdefaults
```

## usage

to enable the plugin, add `covdefaults` to your coverage plugins

in `.coveragerc`:

```ini
[run]
plugins = covdefaults
```

in `setup.cfg` / `tox.ini`:

```ini
[coverage:run]
plugins = covdefaults
```

in `pyproject.toml`:

```ini
[tool.coverage.run]
plugins = ["covdefaults"]
```

## default settings

### `[coverage:run]`

```ini
branch = True
source = .
omit =
    */__main__.py
    */setup.py
```

### `[coverage:report]`

```ini
show_missing = True
skip_covered = True
fail_under = 100
exclude_lines =
    # a more strict default pragma
    \# pragma: no cover\b

    # allow defensive code
    ^\s*raise AssertionError\b
    ^\s*raise NotImplementedError\b
    ^\s*return NotImplemented\b
    ^\s*raise$

    # typing-related code
    ^\s*if (False|TYPE_CHECKING):
    : \.\.\.(\s*#.*)?$
    ^ +\.\.\.$
    -> ['"]?NoReturn['"]?:

    # non-runnable code
    if __name__ == ['"]__main__['"]:$

    # additional platform related pragmas (see below)
    # additional version related pragmas (see below)
partial_branches =
    # a more strict default pragma
    \# pragma: no cover\b

    # out platform pragmas
    \# pragma: (nt|posix|cygwin|darwin|linux|msys|win32|cpython|pypy) (no )?cover\b

    # our version pragmas
    \# pragma: (>=?|<=?|==|!=)\d+\.\d+ cover\b
```

### platform specific `# pragma: no cover`

several `# pragma: no cover` tags will be added automatically based on the
platform and implementation.

these will be in the form of:

```python
# pragma: TAG no cover
```

or

```python
# pragma: TAG cover
```

these tags will be generated by the following values:

- `os.name`
    - `nt` (windows)
    - `posix` (linux, macOs, cygwin, etc.)
- `sys.platform`
    - `cygwin`
    - `darwin` (macOs)
    - `linux`
    - `msys`
    - `win32`
- `sys.implementation.name`
    - `cpython`
    - `pypy`

for every tag which does not match, you can use negation.  here's an example:

```python
if sys.platform == 'win32':  # pragma: win32 cover
    bin_dir = 'Scripts'
else:  # pragma: win32 no cover
    bin_dir = 'bin'
```

note here that `# pragma: win32 cover` will become a "no cover" for everything
which is not `win32` -- whereas the `# pragma: win32 no cover` will be a
"no cover" only on `win32`.

### version specific `# pragma: no cover`

several `# pragma: no cover` tags will be added automatically based on the
platform and implementation.

these will be in the form of:

```python
# pragma: >=#.# cover
```

where the comparison operator is one of `>`, `>=`, `<`, `<=`, `==`, `!=`

for example:

```python
if sys.version_info >= (3, 9):  # pragma: >=3.9 cover
    print('3.9+')
else:  # pragma: <3.9 cover
    print('old')
```

### overriding options

several of the options can be overridden / extended in your coverage
configuration.  the examples below assume `.coveragerc` however any of the
files `coverage` supports work as well.

#### `run:omit`

```ini
[run]
omit =
    pre_commit/resources/*
```

this will result in the `pre_commit/resources/*` being `omit`ted in addition
to the defaults provided by `covdefaults`.

```ini
[covdefaults]
subtract_omit = */__main__.py
```

this will result in `*/__main__.py` not being `omit`ted (`*/__main__.py` is
among the defaults provided by `covdefaults`).

#### `run:source`

```ini
[run]
source = $PWD
```

covdefaults will not override this value to `.` if it is set manually.

#### `report:exclude_lines`

```ini
[report]
exclude_lines =
    ^if MYPY:$
```

this will result in lines matching `^if MYPY:$` to additionally be excluded
from coverage in addition to the defaults provided by `covdefaults`.

#### `report:fail_under`

```ini
[report]
fail_under = 90
```

`covdefaults` will not change the value if you provide one for `fail_under`

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/asottile/covdefaults",
    "name": "covdefaults",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Anthony Sottile",
    "author_email": "asottile@umich.edu",
    "download_url": "https://files.pythonhosted.org/packages/9b/24/36a45f0734a1553ccbbd92683af7369bc919dce219ff42f921323d0be7db/covdefaults-2.2.2.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://dev.azure.com/asottile/asottile/_apis/build/status/asottile.covdefaults?branchName=main)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=62&branchName=main)\n[![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/asottile/asottile/62/main.svg)](https://dev.azure.com/asottile/asottile/_build/latest?definitionId=62&branchName=main)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/asottile/covdefaults/main.svg)](https://results.pre-commit.ci/latest/github/asottile/covdefaults/main)\n\ncovdefaults\n===========\n\nA coverage plugin to provide sensible default settings\n\n## installation\n\n```bash\npip install covdefaults\n```\n\n## usage\n\nto enable the plugin, add `covdefaults` to your coverage plugins\n\nin `.coveragerc`:\n\n```ini\n[run]\nplugins = covdefaults\n```\n\nin `setup.cfg` / `tox.ini`:\n\n```ini\n[coverage:run]\nplugins = covdefaults\n```\n\nin `pyproject.toml`:\n\n```ini\n[tool.coverage.run]\nplugins = [\"covdefaults\"]\n```\n\n## default settings\n\n### `[coverage:run]`\n\n```ini\nbranch = True\nsource = .\nomit =\n    */__main__.py\n    */setup.py\n```\n\n### `[coverage:report]`\n\n```ini\nshow_missing = True\nskip_covered = True\nfail_under = 100\nexclude_lines =\n    # a more strict default pragma\n    \\# pragma: no cover\\b\n\n    # allow defensive code\n    ^\\s*raise AssertionError\\b\n    ^\\s*raise NotImplementedError\\b\n    ^\\s*return NotImplemented\\b\n    ^\\s*raise$\n\n    # typing-related code\n    ^\\s*if (False|TYPE_CHECKING):\n    : \\.\\.\\.(\\s*#.*)?$\n    ^ +\\.\\.\\.$\n    -> ['\"]?NoReturn['\"]?:\n\n    # non-runnable code\n    if __name__ == ['\"]__main__['\"]:$\n\n    # additional platform related pragmas (see below)\n    # additional version related pragmas (see below)\npartial_branches =\n    # a more strict default pragma\n    \\# pragma: no cover\\b\n\n    # out platform pragmas\n    \\# pragma: (nt|posix|cygwin|darwin|linux|msys|win32|cpython|pypy) (no )?cover\\b\n\n    # our version pragmas\n    \\# pragma: (>=?|<=?|==|!=)\\d+\\.\\d+ cover\\b\n```\n\n### platform specific `# pragma: no cover`\n\nseveral `# pragma: no cover` tags will be added automatically based on the\nplatform and implementation.\n\nthese will be in the form of:\n\n```python\n# pragma: TAG no cover\n```\n\nor\n\n```python\n# pragma: TAG cover\n```\n\nthese tags will be generated by the following values:\n\n- `os.name`\n    - `nt` (windows)\n    - `posix` (linux, macOs, cygwin, etc.)\n- `sys.platform`\n    - `cygwin`\n    - `darwin` (macOs)\n    - `linux`\n    - `msys`\n    - `win32`\n- `sys.implementation.name`\n    - `cpython`\n    - `pypy`\n\nfor every tag which does not match, you can use negation.  here's an example:\n\n```python\nif sys.platform == 'win32':  # pragma: win32 cover\n    bin_dir = 'Scripts'\nelse:  # pragma: win32 no cover\n    bin_dir = 'bin'\n```\n\nnote here that `# pragma: win32 cover` will become a \"no cover\" for everything\nwhich is not `win32` -- whereas the `# pragma: win32 no cover` will be a\n\"no cover\" only on `win32`.\n\n### version specific `# pragma: no cover`\n\nseveral `# pragma: no cover` tags will be added automatically based on the\nplatform and implementation.\n\nthese will be in the form of:\n\n```python\n# pragma: >=#.# cover\n```\n\nwhere the comparison operator is one of `>`, `>=`, `<`, `<=`, `==`, `!=`\n\nfor example:\n\n```python\nif sys.version_info >= (3, 9):  # pragma: >=3.9 cover\n    print('3.9+')\nelse:  # pragma: <3.9 cover\n    print('old')\n```\n\n### overriding options\n\nseveral of the options can be overridden / extended in your coverage\nconfiguration.  the examples below assume `.coveragerc` however any of the\nfiles `coverage` supports work as well.\n\n#### `run:omit`\n\n```ini\n[run]\nomit =\n    pre_commit/resources/*\n```\n\nthis will result in the `pre_commit/resources/*` being `omit`ted in addition\nto the defaults provided by `covdefaults`.\n\n```ini\n[covdefaults]\nsubtract_omit = */__main__.py\n```\n\nthis will result in `*/__main__.py` not being `omit`ted (`*/__main__.py` is\namong the defaults provided by `covdefaults`).\n\n#### `run:source`\n\n```ini\n[run]\nsource = $PWD\n```\n\ncovdefaults will not override this value to `.` if it is set manually.\n\n#### `report:exclude_lines`\n\n```ini\n[report]\nexclude_lines =\n    ^if MYPY:$\n```\n\nthis will result in lines matching `^if MYPY:$` to additionally be excluded\nfrom coverage in addition to the defaults provided by `covdefaults`.\n\n#### `report:fail_under`\n\n```ini\n[report]\nfail_under = 90\n```\n\n`covdefaults` will not change the value if you provide one for `fail_under`\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A coverage plugin to provide sensible default settings",
    "version": "2.2.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "9c0066306767c94420834786d3d2eee4",
                "sha256": "10c193cbf290675961a09166d7cdea8a783655e04009f5493d50685fe6ec82f3"
            },
            "downloads": -1,
            "filename": "covdefaults-2.2.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9c0066306767c94420834786d3d2eee4",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 5210,
            "upload_time": "2022-12-03T17:45:54",
            "upload_time_iso_8601": "2022-12-03T17:45:54.071435Z",
            "url": "https://files.pythonhosted.org/packages/be/95/a5ffc4a639de5ab121c4158a53ee09f51f05cb9e1874c33e2c3eb5bf3185/covdefaults-2.2.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "343da7813d47792d321d6b60a356f600",
                "sha256": "e543862ee0347769b47b27fa586d690e6b91587a3dcaaf8552fcfb1fac03d061"
            },
            "downloads": -1,
            "filename": "covdefaults-2.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "343da7813d47792d321d6b60a356f600",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4934,
            "upload_time": "2022-12-03T17:45:55",
            "upload_time_iso_8601": "2022-12-03T17:45:55.902440Z",
            "url": "https://files.pythonhosted.org/packages/9b/24/36a45f0734a1553ccbbd92683af7369bc919dce219ff42f921323d0be7db/covdefaults-2.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-03 17:45:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "asottile",
    "github_project": "covdefaults",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "covdefaults"
}
        
Elapsed time: 0.01428s