-
Notifications
You must be signed in to change notification settings - Fork 157
Add pre-commit and Ruff setup with flake8 and other codestyle checks #2531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b57872b
to
1118647
Compare
1118647
to
d9bfebd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me and seems to be working well. I just had one minor comment (about a comment).
So if I'm understanding correctly, the idea is to put permanent rule exclusions in pyproject.toml
, while the ones in ruff.toml
are "we should fix these at some point"?
extend = "pyproject.toml" | ||
lint.ignore = [ | ||
# NOTE: to find a good code to fix, run: | ||
# ruff --select="ALL" --statistics glue/<subpackage> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be ruff check --select="ALL" --statistics glue/<package>
(the check
is missing currently)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting this; yes, probably referred to a deprecated way of invoking ruff with "check" set as default action.
Yes, that would be largely following Astropy policy, which at least @astrofrog and I are reasonably familiar with. The last set is now already in |
Ah yeah, I see now that you had said that in the original PR description too - sorry for not reading more carefully! That certainly sounds reasonable to me, and if it's worked for Astropy then I imagine it works quite well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Description
This PR is adding
ruff check
as a linter in place of, among other checks, the currentcodestyle
CI test. The setup is largely following the Astropy example with global and per-file ignores for all checks not passing in the present codebase. Like in Astropy, rules considered not applicable are placed as permanent exemptions inpyproject.toml
, while currently failing roles are put in.ruff.toml
, to be fixed in the code at a given time.pre-commit
setup making this Ruff installation available as a local pre-commit hook and as runner for thecodestyle
job.For usage I refer again to the Astropy documentation above; basic options for local usage are running
pre-commit install
to have checks (and where possible fixes) automatically applied on each commitpre-commit run [--all-files]
to manually check staged files or the entire reporuff check
to directly run the linting checks with Ruff.Fixes to the actual files, especially those with per-file exemptions at the end of
.ruff.toml
can be done in a follow-up step.