Thresholds & CI Mode¶
Thresholds¶
The mapping between individual function statuses and the overall module status is controlled by four percentage thresholds:
| Option | Default | Meaning |
|---|---|---|
threshold_bad | 80 | Above this share of bad → module is bad. |
threshold_warning | 60 | Above this share of bad → module is warning. |
threshold_special | 50 | Above this share of special → module is special. |
threshold_epic | 50 | Above this share of epic → module is epic. |
Override them on the command line:
docstr-health --threshold-bad 70 --threshold-warning 50
Or in pyproject.toml:
[tool.docstr-health]
threshold_bad = 70
threshold_warning = 50
threshold_special = 60
threshold_epic = 40
CI mode¶
Enable CI mode with --ci (or ci = true in the config):
docstr-health --ci /path/to/project
In CI mode:
- All terminal output is suppressed — useful in pipelines.
- The process exits with code
1when the project status is at or below the configuredfailure_level.
The failure level is set with failure_level (default warning):
[tool.docstr-health]
ci = true
failure_level = "good"
Statuses are ordered bad < warning < good < special < epic, so failure_level = "good" fails the build unless the project achieves at least special.
Exit codes¶
| Code | Meaning |
|---|---|
0 | Success. |
1 | CI failure, or an unrecoverable DocstrHealthError occurred. |
Example GitHub Actions step¶
- name: Check docstring health
run: |
pip install docstr-health
docstr-health --ci --threshold-warning 50
Pre-commit hook¶
You can run docstr-health as a pre-commit hook. Add this to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/PurpleSwtr/docstr-health
rev: v0.1.5 # use the latest tag
hooks:
- id: docstr-health
The hook runs docstr-health --ci on the repository root (pass_filenames: false), so it checks the whole project whenever a Python file is committed.
Override arguments to match your policy:
repos:
- repo: https://github.com/PurpleSwtr/docstr-health
rev: v0.1.5
hooks:
- id: docstr-health
args: [--ci, --threshold-warning, "50", --ignore-tests]
Note
CI mode is enabled by default in the hook. Configure failure_level and thresholds in pyproject.toml or pass them via args.