Skip to content

Conversation

@VeckoTheGecko
Copy link
Contributor

@VeckoTheGecko VeckoTheGecko commented Feb 2, 2026

  • Closes None

I realised that there isn't any(?) linting of docstrings to make sure they adhere to the numpydoc style guide.

This PR adds a script and Pixi integration to quickly lint public docstrings. This is a similar script to that introduced in Scipy (scipy/scipy#24317 ) - though I wrote my own version which I think is a bit more robust in finding all the methods :) .

Note that numpydoc does have validation out of the box however this is on a file level, and not on the public API level (this applies to the CLI tool, pre-commit hook, and for numpydoc's integration in Sphinx - all are on the file level) - hence our need for this script.

I've used this script to find a heap of minor typos in the docs which I'll wrap into another PR.

I don't know if we can integrate this into a pre-commit hook as it requires building xarray.

ROOT_PACKAGE = "xarray"

# full list of numpydoc error codes: https://numpydoc.readthedocs.io/en/latest/validation.html
SKIP_ERRORS = [ # TODO: Curate these for Xarray
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These error code skips have mostly been inherited from my work on Parcels. These can be updated (though would be good to have input from core devs here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is doc a good place for this script?

@VeckoTheGecko VeckoTheGecko mentioned this pull request Feb 2, 2026
1 task
try:
res = validate(item)
except (AttributeError, StopIteration, ValueError) as e:
if isinstance(e, ValueError) and "Error parsing See Also entry" in str(e): # TODO: Fix later https://github.com/pydata/xarray/issues/8596#issuecomment-3832443795
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant