Skip to content

Unleash numpydoc pre-commit - #20284

Merged
pllim merged 13 commits into
astropy:mainfrom
pllim:unleash-numpydoc-precommit
Sep 9, 2026
Merged

pllim merged 13 commits into
astropy:mainfrom
pllim:unleash-numpydoc-precommit

Conversation

@pllim

@pllim pllim commented Aug 27, 2026

Copy link
Copy Markdown
Member

Description

This pull request is to close #15386

TODO

  • Allow time for discussions among devs
  • Tweak settings based on feedback
  • Make the check green
  • Update dev docs
  • ???
  • Profit!!!
  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@pllim
pllim marked this pull request as ready for review August 27, 2026 16:49
@pllim
pllim requested review from astrofrog and taldcroft August 27, 2026 16:49
@timj

timj commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

We use this at Rubin a lot and it's very helpful. My only caveat is that it only helps if there is a prek (faster pre-commit) github action to check that the code is compliant for people who don't use pre-commit. I didn't see such an action but maybe it's got a different name.

@pllim

pllim commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

for people who don't use pre-commit

I don't think it is a problem for us. Our developer guide clearly states that we use pre-commit and we expect them to.

@timj

timj commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

what's the downside of adding the github action though? That will let people know who forgot to read that and are doing their first PR and will be a no-op for people who are following the guidelines. The pre-commit action is trivial to add: https://github.com/lsst/images/blob/main/.github/workflows/pre-commit.yaml will work directly as is for you.

@pllim

pllim commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

Re: prek -- Please open a new issue to discuss this, as I think that topic is a little out of scope here.

Personally, I don't see the point. I don't know who j178 and it is very obvious when pre-commit job fails.

@timj

timj commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

very obvious when pre-commit job fails

Oh. So you already have a pre-commit github action. I misunderstood.

Comment thread pyproject.toml
'\.__str__$',
'\.__repr__$',
]
exclude_files = [ # don't process filepaths that match these regex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So does this leave any files that are actually checked, or is it just a proof of concept for the pre-commit job at this point (or will pre-commit still check new files)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, currently I ignored everything to get the pre-commit job to pass. I envision where I could possibly remove one of the ignores and fix it as POC for this PR. But the rest can be a series of small(ish) follow-up PRs. Eventually we would only ignore the stuff we don't care about (tests, deprecated modules, etc).

@neutrinoceros

Copy link
Copy Markdown
Contributor

So you already have a pre-commit github action.

technically: no. We run pre-commit.ci, which is a separate service than Github Actions.

re: prek
This is a client-side alternative to pre-commit. As far as I can tell after months using it, it seems perfectly backwards compatible with the historical implementation, and it's indeed faster, but our hooks are fast enough already that I'd rather we keep advertise the rock solid, reference pre-commit implementation instead. Individual developers in the know may still choose to run prek locally, but that's a personal choice we have no interest in promoting.

@timj

timj commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

I wasn't trying to confuse things by advocating prek on the client side. I was saying that I was using prek on the GitHub action side but since you do have a separate pre-commit CI run then that was irrelevant.

@astrofrog

astrofrog commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

@pllim how did you choose the config (ie what to exclude) - was this copied from another package?

@pllim

pllim commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

how did you choose

I was locked in a mansion with them, then every night I presented one of them with a rose until these are left.

jk jk

I started with jwst settings and then I went through many iterations in this PR, looked at the pre-commit logs, and decided which ones I didn't care about.

That is why the first TODO item is dev discussions, so we can fine-tune the lists. 😺

@astrofrog

Copy link
Copy Markdown
Member

Sounds good. I’m on my phone so can't do it right now but we should also compare to the reproject config.

Comment thread pyproject.toml
"""

[tool.numpydoc_validation]
checks = [

@pllim pllim Aug 27, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@astrofrog here is the reproject settings:

[tool.numpydoc_validation]
checks = [
    "all",   # report on all checks, except the below
    "EX01",
    "SA01",
    "SS06",
    "ES01",
    "GL08",
]

At the time of writing, reproject list is a subset of this proposed PR.

Comment thread pyproject.toml
'^astropy/constants/.*',
'^astropy/convolution/.*',
'^astropy/coordinates/.*',
'^astropy/cosmology/.*',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👁️
Color me interested in addressing this.

pllim added 10 commits September 5, 2026 00:40
[ci skip]
[ci skip]
[ci skip]
[ci skip]
[ci skip]
[ci skip]
[ci skip]
[ci skip]
@astrofrog
astrofrog force-pushed the unleash-numpydoc-precommit branch from 76b795a to f5b30da Compare September 4, 2026 23:40
@astrofrog

Copy link
Copy Markdown
Member

@pllim - rebased just to see if CI is happier

@astrofrog astrofrog left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I personally think we should just do that and we can always tweak the config the first time we address one of the subpackages

@pllim

pllim commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

So @astrofrog , do you want me to check off any of those TODO items here? Or you just want to merge this as-is? At least the devdocs?

@pllim

pllim commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Tom R said no need for devdocs. So merging!

@pllim
pllim merged commit ad9d20f into astropy:main Sep 9, 2026
2 checks passed
@pllim
pllim deleted the unleash-numpydoc-precommit branch September 9, 2026 18:07
@pllim

pllim commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Follow-up issue is #20353

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.

Use numpydoc pre-commit

6 participants