Registry / testing / docstr-coverage

docstr-coverage

JSON →
library2.3.2pypypi✓ verified 84d ago

docstr-coverage is a Python utility that scans source files to ensure proper documentation. It identifies missing docstrings, provides a detailed report, and calculates an overall docstring coverage percentage. The current version is 2.3.2, and it follows an infrequent but active release cadence, typically releasing minor versions a few times a year.

pip install docstr-coverage
INSTALL
IMPORT
SIG · DOCSTR-COVERAGE
D
docstr-coverage
testingpythonv2.3.2
Install
2.0s avg
Import
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.3.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.0s · import 0.000s · 23MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_docstring_coverage
from docstr_coverage import get_docstring_coverage
from docstr_coverage import get_docstr_coverage

The primary usage of docstr-coverage is via the command line, but it also exposes a programmatic API. This example demonstrates how to use `get_docstr_coverage` to analyze a Python file and print the results. For CLI usage, simply run `docstr-coverage your_project/`.

import os from docstr_coverage import get_docstr_coverage # Create a dummy file for demonstration with open('example_module.py', 'w') as f: f.write("""""""Module docstring."""\n class MyClass:\n """Class docstring."""\n def __init__(self):\n # No docstring here - this will be reported\n pass\n\n def my_method(self, arg):\n """Method docstring."""\n return arg * 2\n""") # Run docstr-coverage programmatically report = get_docstr_coverage( paths=['example_module.py'], skip_init=False, skip_magic=True, skip_private=False, skip_class_innards=False, verbose=2 ) print(f"\nOverall coverage: {report['overall_coverage']:.2f}%") if report['missing_docstrings']: print("\nMissing docstrings found:") for item in report['missing_docstrings']: print(f" - {item['file']}:{item['line']} ({item['name']}) -> {item['type']}") # Clean up dummy file os.remove('example_module.py')
docstr-coverage --version
Debug
Known issues
breakingConfiguration options (e.g., in `pyproject.toml` or `setup.cfg`) changed from `camelCase` to `snake_case`.
fix
Update all configuration options in your project's configuration files (e.g., `pyproject.toml`) to use `snake_case`. For example, `failUnder` becomes `fail_under`.
affects: >=2.0.0
gotchaThe `docstr-coverage` CLI returns non-zero exit codes (e.g., 1 for failing `--fail-under`, 2 for argument errors). This can cause CI/CD pipelines to fail unexpectedly.
fix
In CI/CD scripts, be aware of the exit codes. Configure your CI system to expect specific exit codes or wrap the command with `|| true` if you only want to log warnings without failing the build based on docstring coverage.
affects: All versions
gotchaIncorrect usage of exclusion flags like `--skip` or `--exclude` can lead to either files being unexpectedly included or crucial files being ignored.
fix
Carefully review the documentation for `--skip` (for individual docstring types) and `--exclude` (for file paths). Use glob patterns for `--exclude` paths, and test your configuration thoroughly to ensure the correct files and docstring types are being evaluated.
affects: All versions
Upgrade
Version history
2.3.2latest on PyPI · released May 7, 2024
Audit
Dependencies
tomlrequiredRequired for parsing TOML configuration files (e.g., pyproject.toml).
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
docstr-coverage — pip install docstr-coverage · libregistry