From 9771c2b9922fe6d1a0c248541996b27123965d75 Mon Sep 17 00:00:00 2001 From: Jan Gleixner Date: Wed, 11 Nov 2026 09:26:13 +0100 Subject: [PATCH 1/2] ci: check docstring parameters against signatures with pydoclint (SIT-422) Adds pydoclint as a pre-commit hook on src/, configured in [tool.pydoclint] in pyproject.toml (noted on the hook, as asked in review). Builds on the docstring fixes in jangleixner/sit-422-docstring-fixes. --- .pre-commit-config.yaml | 6 ++++++ pyproject.toml | 15 +++++++++++++++ src/spatialdata/_core/query/spatial_query.py | 2 +- src/spatialdata/models/models.py | 4 ++-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a6258fd8..b63132efe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,12 @@ repos: args: [--fix, --exit-non-zero-on-fix] - id: ruff-format groups: [format] + - repo: https://github.com/jsh9/pydoclint + rev: 0.12.0 + hooks: + # Checks docstring parameters against signatures. Options live in [tool.pydoclint] in pyproject.toml. + - id: pydoclint + files: ^src/ - repo: local hooks: - id: mypy diff --git a/pyproject.toml b/pyproject.toml index c034b9058..2d4989fb4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -277,9 +277,24 @@ lint.per-file-ignores."tests/*" = [ "B024", "D", "PT" ] lint.per-file-ignores."tests/conftest.py" = [ "E402" ] lint.per-file-ignores."tests/test_models/test_models.py" = [ "NPY002" ] lint.unfixable = [ "B", "BLE", "C4", "RET", "T20", "UP" ] +lint.external = [ "DOC1" ] # pydoclint parameter checks, see [tool.pydoclint] lint.isort.required-imports = [ "from __future__ import annotations" ] lint.pydocstyle.convention = "numpy" +[tool.pydoclint] +# Check that documented parameters match the function signature (missing or stale names, #1303), +# and that Returns/Yields sections exist. Types (they live in the signatures), order and raises are not checked. +# Docstrings with only a summary (no Parameters section) are skipped. +style = "numpy" +allow-init-docstring = true +arg-type-hints-in-docstring = false +check-return-types = false +check-yield-types = false +skip-checking-raises = true +check-class-attributes = false +check-arg-order = false +omit-stars-when-documenting-varargs = true + [tool.mypy] # TODO: extend to "tests" once the test suite carries type annotations. files = [ "src" ] diff --git a/src/spatialdata/_core/query/spatial_query.py b/src/spatialdata/_core/query/spatial_query.py index f0360c310..7ef04399d 100644 --- a/src/spatialdata/_core/query/spatial_query.py +++ b/src/spatialdata/_core/query/spatial_query.py @@ -527,7 +527,7 @@ def bounding_box_query( ----- If the object has `points` element, depending on the number of points, it MAY suffer from performance issues. Please consider filtering the object before calling this function by calling the `subset()` method of `SpatialData`. - """ + """ # noqa: DOC101, DOC103 (**kwargs only exists for singledispatch; nothing extra is accepted) raise RuntimeError("Unsupported type for bounding_box_query: " + str(type(element)) + ".") diff --git a/src/spatialdata/models/models.py b/src/spatialdata/models/models.py index a8d10d87c..f007b5670 100644 --- a/src/spatialdata/models/models.py +++ b/src/spatialdata/models/models.py @@ -622,7 +622,7 @@ def parse(cls, data: Any, **kwargs: Any) -> GeoDataFrame: Returns ------- :class:`geopandas.GeoDataFrame` - """ + """ # noqa: DOC102, DOC103 (parameters of the registered implementations) raise TypeError(f"ShapesModel.parse() does not support the type {type(data)}") @parse.register(np.ndarray) @@ -788,7 +788,7 @@ def parse(cls, data: Any, **kwargs: Any) -> DaskDataFrame: ----- The order of the columns of the dataframe returned by the parser is not guaranteed to be the same as the order of the columns in the dataframe passed as an argument. - """ + """ # noqa: DOC102, DOC103 (parameters of the registered implementations) raise TypeError(f"PointsModel.parse() does not support the type {type(data)}") @parse.register(np.ndarray) From 1a2121adf6b9278cda58f06f8d86c4e368b38927 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:38:03 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- src/spatialdata/_core/query/spatial_query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spatialdata/_core/query/spatial_query.py b/src/spatialdata/_core/query/spatial_query.py index dc9d7956b..5f2616158 100644 --- a/src/spatialdata/_core/query/spatial_query.py +++ b/src/spatialdata/_core/query/spatial_query.py @@ -524,7 +524,7 @@ def bounding_box_query( Shapes are not cut to the bounding box: a shape that intersects it is returned whole. For a `MultiPolygon` this includes components that lie entirely outside the bounding box. To cut the shapes to the bounding box, use :func:`polygon_query` with `clip=True` and the bounding box as polygon, e.g. `shapely.box(xmin, ymin, xmax, ymax)`. - """ # noqa: DOC101, DOC103 (**kwargs only exists for singledispatch; nothing extra is accepted) + """ # noqa: DOC101, DOC103 (**kwargs only exists for singledispatch; nothing extra is accepted) raise RuntimeError("Unsupported type for bounding_box_query: " + str(type(element)) + ".")