{"id":15642540,"url":"https://github.com/asottile/covdefaults","last_synced_at":"2025-07-12T02:41:00.583Z","repository":{"id":37939655,"uuid":"244042058","full_name":"asottile/covdefaults","owner":"asottile","description":"A coverage plugin to provide sensible default settings","archived":false,"fork":false,"pushed_at":"2025-03-31T21:00:44.000Z","size":240,"stargazers_count":78,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T12:53:20.336Z","etag":null,"topics":["coverage","pytest"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asottile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"asottile"}},"created_at":"2020-02-29T21:10:47.000Z","updated_at":"2025-03-31T21:00:50.000Z","dependencies_parsed_at":"2023-10-04T00:54:55.447Z","dependency_job_id":"ad886b51-7f67-4e45-88b5-ee6bc750c310","html_url":"https://github.com/asottile/covdefaults","commit_stats":{"total_commits":163,"total_committers":4,"mean_commits":40.75,"dds":0.2638036809815951,"last_synced_commit":"fed827293cce40337bdec81b1bbf02446beb1278"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asottile%2Fcovdefaults","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asottile%2Fcovdefaults/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asottile%2Fcovdefaults/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asottile%2Fcovdefaults/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asottile","download_url":"https://codeload.github.com/asottile/covdefaults/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553959,"owners_count":22090417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coverage","pytest"],"created_at":"2024-10-03T11:56:44.337Z","updated_at":"2025-05-16T15:06:41.075Z","avatar_url":"https://github.com/asottile.png","language":"Python","funding_links":["https://github.com/sponsors/asottile"],"categories":[],"sub_categories":[],"readme":"[![build status](https://github.com/asottile/covdefaults/actions/workflows/main.yml/badge.svg)](https://github.com/asottile/covdefaults/actions/workflows/main.yml)\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    -\u003e ['\"]?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    # our platform pragmas\n    \\# pragma: (nt|posix|cygwin|darwin|linux|msys|win32|cpython|pypy) (no )?cover\\b\n\n    # our version pragmas\n    \\# pragma: (\u003e=?|\u003c=?|==|!=)\\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: \u003e=#.# cover\n```\n\nwhere the comparison operator is one of `\u003e`, `\u003e=`, `\u003c`, `\u003c=`, `==`, `!=`\n\nfor example:\n\n```python\nif sys.version_info \u003e= (3, 9):  # pragma: \u003e=3.9 cover\n    print('3.9+')\nelse:  # pragma: \u003c3.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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasottile%2Fcovdefaults","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasottile%2Fcovdefaults","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasottile%2Fcovdefaults/lists"}