Skip to content

ci: check docstring parameters against signatures (pydoclint, SIT-422) - #1306

Open
jan-glx wants to merge 4 commits into
scverse:mainfrom
jan-glx:jangleixner/sit-422-docstring-signature-check
Open

jan-glx wants to merge 4 commits into
scverse:mainfrom
jan-glx:jangleixner/sit-422-docstring-signature-check

Conversation

@jan-glx

@jan-glx jan-glx commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1303 (SIT-422).

Adds pydoclint as a pre-commit hook on src/, so CI catches docstrings that document parameters a function doesn't have, or miss ones it does (the #1273 / #1254 kind of drift).

Config ([tool.pydoclint] in pyproject.toml), kept narrow on purpose:

  • numpy style; class docstrings may document __init__ parameters (allow-init-docstring)
  • checks: missing or stale parameter names, and that Returns/Yields sections exist
  • not checked: types (they live in the signatures), argument order, raises
  • kwargs may be documented without stars, as the codebase already does
  • docstrings with only a summary (no Parameters section) are skipped, so terse private helpers aren't affected

Why pydoclint over numpydoc's PR01/PR02 validation: numpydoc also flags every docstring that has no Parameters section (~100 hits here, mostly private helpers). pydoclint only checks docstrings that do document parameters, so its findings are actual drift.

Fixes for what it found (docstring-only):

  • get_extent: most parameters were filed under Returns, and the return value was described wrongly
  • _bounding_box_mask_points: a leftover PLACEHOLDER block, and the shared min/max coordinate docs pasted in twice
  • Returns/Notes sections that didn't parse (indented body, ------- underline)
  • undocumented parameters: c_coords (blobs), suppress_z_warning, sdata, zarr_path, intermediate_coordinate_systems, …
  • added missing Returns/Yields sections

Two kinds of intentional mismatch keep their docs, with a # noqa: ShapesModel.parse / PointsModel.parse document the parameters of their singledispatch overloads, and bounding_box_query's **kwargs exists only for singledispatch (no overload accepts extra arguments), so it stays undocumented. lint.external = ["DOC1"] stops ruff's RUF100 from flagging those noqa comments as unused.

…-422)

Add pydoclint (numpy style) as a pre-commit hook on src/, configured to check
that documented parameters match the function signature (missing and stale
names) and that Returns/Yields sections exist. Types, argument order and
raises are not checked. Class docstrings may document __init__ parameters.

Fix the drift it finds, e.g. get_extent documenting its parameters under
Returns, Returns/Notes sections that did not parse, a duplicated
PLACEHOLDER block in _bounding_box_mask_points, and undocumented parameters
(c_coords in blobs, suppress_z_warning, sdata, zarr_path, ...).

Closes scverse#1303
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.43%. Comparing base (df139eb) to head (f29ebdc).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1306   +/-   ##
=======================================
  Coverage   91.43%   91.43%           
=======================================
  Files          53       53           
  Lines        8395     8395           
=======================================
  Hits         7676     7676           
  Misses        719      719           
Files with missing lines Coverage Δ
src/spatialdata/_core/centroids.py 100.00% <ø> (ø)
src/spatialdata/_core/data_extent.py 97.97% <ø> (ø)
src/spatialdata/_core/operations/aggregate.py 89.21% <ø> (ø)
src/spatialdata/_core/operations/rasterize.py 91.43% <ø> (ø)
src/spatialdata/_core/query/relational_query.py 93.34% <ø> (ø)
src/spatialdata/_core/query/spatial_query.py 95.01% <ø> (ø)
src/spatialdata/_core/spatialdata.py 93.46% <ø> (ø)
src/spatialdata/_core/validation.py 100.00% <ø> (ø)
src/spatialdata/_io/_utils.py 87.13% <ø> (ø)
src/spatialdata/_io/io_raster.py 87.65% <ø> (ø)
... and 12 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jan-glx
jan-glx marked this pull request as ready for review November 9, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: check docstring parameters against signatures

1 participant