Skip to content

Widen numpydoc-validation checks across causalpy#902

Open
drbenvincent wants to merge 8 commits into
mainfrom
issue-898-numpydoc-validation-expansion
Open

Widen numpydoc-validation checks across causalpy#902
drbenvincent wants to merge 8 commits into
mainfrom
issue-898-numpydoc-validation-expansion

Conversation

@drbenvincent
Copy link
Copy Markdown
Collaborator

Closes #898.

Summary

  • Broaden the numpydoc-validation pre-commit hook from the original .plot-only scope to the whole causalpy/ package (tests/ and data/ excluded), and trade the .plot-only exclude regex for a private-member exclude (\._).
  • Enable the curated list of new rules requested in the issue, one per commit to keep the diff reviewable: PR04, PR07, PR10, RT03, SS03, GL07, GL08.
  • Replace the standalone interrogate hook with GL08 (per the agreed-upon resolution of the overlap discussed in the issue): the pre-commit hook, [tool.interrogate] config, extras entries, the interrogate-badge workflow, the Makefile invocation, and the README badge are all removed.
  • Fix every violation that surfaces under the broadened scope. The bulk of the work is in commit 1: converting the remaining Sphinx :param: blocks in causalpy/experiments/* to numpydoc Parameters sections, documenting forwarded *args/**kwargs, fleshing out protocol/check/maketables/skl helper docstrings, and tidying a See Also entry in utils.py that previously broke the docstring parser. Subsequent commits include only small, rule-scoped fixes.

Commit-by-commit breakdown

  1. Broaden numpydoc-validation scope across causalpy/ — config + all PR01/PR02 violations under the new scope.
  2. Enable PR04 (parameter has no type) — config only, no violations.
  3. Enable PR07 (parameter has no description) — config only, no violations.
  4. Enable PR10 (space before colon) — config only, no violations.
  5. Enable RT03 (return value has no description) — flesh out Check.run's return entry.
  6. Enable SS03 (summary ends with period) — fix module- and method-level summaries that lacked a trailing period.
  7. Enable GL07 (section ordering) — reorder Examples/Notes/See Also blocks in InterruptedTimeSeries, PiecewiseITS, PyMCModel.priors_from_data, and the variable-selection-prior classes (the latter previously used a non-standard singular Example heading).
  8. Enable GL08 and replace interrogate with numpydoc-validation — drop the interrogate hook plumbing; add a top-level package docstring and flesh out abstract fit/build_model/calculate_cumulative_impact stubs; rename two nested helpers in InversePropensityWeighting._plot_weights_propensity to _-prefixed names so they fall under the configured private exclude.

Decisions / clarifications recorded in the issue thread

  • GL08 vs interrogate: replace interrogate with GL08 (single source of truth for missing-docstring enforcement). All interrogate config, extras, the badge workflow, and the README badge are removed.
  • Single PR with 8 commits: yes — one commit per enabled rule (plus the initial broadening + PR01/PR02 cleanup), as suggested in the acceptance criteria.
  • Exclude private/dunder methods: yes — exclude = ['\._'] so violations on internal helpers don't drown out the public-API signal. The simulated-data helpers in causalpy/data/ are also excluded via the pre-commit files regex; they intentionally retain Sphinx :param: style for didactic clarity.

Test plan

  • prek run --all-files passes (every hook, including numpydoc-validation, mypy, ruff, codespell, PyMarkdown, blank-line-before-bullet-lists, environment.yml sync, etc.).
  • python -c "import causalpy; print(causalpy.__doc__)" succeeds and now prints the new package docstring.
  • pytest causalpy/tests/test_misc.py -x -q passes.
  • CI to re-run the full unit-test suite and docs build.

Made with Cursor

drbenvincent and others added 8 commits May 1, 2026 20:56
Replace the ``.plot``-only exclude regex in ``[tool.numpydoc_validation]`` with a private-member exclude (``\\._``), and widen the pre-commit ``files`` pattern from ``^causalpy/experiments/.*\\.py$`` to ``^causalpy/(?!tests/|data/).*\\.py$`` so the existing ``PR01``/``PR02`` checks now apply package-wide. Document and fix every public-API ``PR01``/``PR02`` violation that surfaces under the new scope: convert remaining Sphinx ``:param:`` blocks to numpydoc ``Parameters`` sections, add missing ``**kwargs``/``*args`` rows, populate the protocol/check/maketables/skl helpers, and tidy a ``See Also`` entry in ``utils.py`` that previously broke the docstring parser. The simulated-data helpers under ``causalpy/data/`` are intentionally excluded for this round; they keep their didactic ``:param`` style.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add ``PR04`` to the numpydoc-validation check set so parameter rows missing a type are caught going forward. No code changes are required: every documented parameter under the package-wide scope already declares a type.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add ``PR07`` to the numpydoc-validation check set so undocumented parameter rows are caught going forward. No code changes are required: every parameter row under the package-wide scope already carries a description.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add ``PR10`` to the numpydoc-validation check set so parameter rows that omit a space before the type colon are caught going forward. No code changes are required: existing docstrings in the broadened scope already conform.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add ``RT03`` to the numpydoc-validation check set so undocumented return rows are caught going forward, and flesh out the bare ``CheckResult`` return entry on the ``Check`` protocol's ``run`` method (the only violation surfaced under the package-wide scope).

Co-authored-by: Cursor <cursoragent@cursor.com>
Add ``SS03`` to the numpydoc-validation check set so first-line summaries that omit a trailing period are caught going forward, and update every docstring under the package-wide scope that previously violated the rule (mostly module-level docstrings and a handful of method summaries).

Co-authored-by: Cursor <cursoragent@cursor.com>
Add ``GL07`` to the numpydoc-validation check set so out-of-order docstring sections are caught going forward. Reorder ``Examples``/``Notes``/``See Also`` blocks in ``InterruptedTimeSeries``, ``PiecewiseITS``, ``PyMCModel.priors_from_data``, and the variable-selection-prior classes (the latter previously used a non-standard singular ``Example`` heading), all to match numpydoc's canonical ordering.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add ``GL08`` (object has no docstring) to the numpydoc-validation check set so missing docstrings are caught the same way every other rule is, and retire the standalone ``interrogate`` hook now that ``numpydoc-validation`` covers the same ground (and more) for the public API. Concretely:

- Drop the ``interrogate`` pre-commit hook, the ``[tool.interrogate]`` section in ``pyproject.toml``, the ``interrogate`` extras entries, the ``interrogate-badge`` workflow, the ``Makefile`` invocation, and the README badge.
- Add a top-level package docstring in ``causalpy/__init__.py`` and flesh out abstract ``fit``/``build_model``/``calculate_cumulative_impact`` stubs that previously had no docstring.
- Rename the nested ``plot_weights``/``make_hists`` helpers in ``InversePropensityWeighting._plot_weights_propensity`` to a leading underscore so they fall under the configured private exclude.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 1, 2026
@drbenvincent drbenvincent changed the title Widen numpydoc-validation checks across causalpy/ (closes #898) Widen numpydoc-validation checks across causalpy May 1, 2026
@drbenvincent drbenvincent requested a review from juanitorduz May 1, 2026 20:09
@drbenvincent
Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor
Copy link
Copy Markdown

cursor Bot commented May 1, 2026

PR Summary

Low Risk
Low risk: changes are largely docstring/validation configuration and removal of an auxiliary coverage badge workflow, with no intended runtime behavior changes beyond internal helper renames.

Overview
Expands numpydoc-validation from a narrow target to the full causalpy/ package (excluding tests/ and data/) and enables a broader curated rule set, while excluding private/dunder members via exclude = ['\._'].

Replaces interrogate-based docstring coverage with GL08 enforcement by removing the interrogate pre-commit hook, config, dev/lint dependencies, Makefile target, README badge, and the interrogate-badge GitHub Actions workflow.

Updates many public APIs and protocols across causalpy to satisfy the new numpydoc rules (adds/standardizes Parameters/Returns, fixes section ordering/periods), and prefixes a couple nested plotting helpers with _ so they’re treated as private under the new exclude regex.

Reviewed by Cursor Bugbot for commit 1f43013. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.73%. Comparing base (48144ba) to head (1f43013).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #902      +/-   ##
==========================================
- Coverage   94.74%   94.73%   -0.02%     
==========================================
  Files          84       84              
  Lines       13131    13131              
  Branches      793      793              
==========================================
- Hits        12441    12439       -2     
- Misses        487      488       +1     
- Partials      203      204       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1f43013. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Widen numpydoc-validation checks beyond PR01/PR02 and beyond .plot methods

1 participant