-
Notifications
You must be signed in to change notification settings - Fork 5
Add pre commit config #68
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
.pre-commit-config.yaml
Outdated
| # - repo: https://github.com/keewis/blackdoc | ||
| # rev: v0.3.9 | ||
| # hooks: | ||
| # - id: blackdoc |
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'll enable that in another PR to avoid a lot of code churn.
.pre-commit-config.yaml
Outdated
| - id: check-ast | ||
| - id: debug-statements | ||
| - id: end-of-file-fixer | ||
| # - id: check-docstring-first |
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.
The code base uses docstrings as a way to do multi-line comment. We need to change that to be able to build clear docs and to run this check.
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.
It passes Ruff as is -- though I think that's a bad practice, so it would be good to clean that up. Maybe now, as that would make for less churn later.
Ideally, major format changes happen all in one commit ...
But your call, either way is good with me.
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 project uses a small subset of all the lints ruff can run. While we can enable "ruff all" at some point, this particular line is focused on better docs rendering. I'll address it later b/c it may require some group discussion.
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'm a bit confused -- we hve ruff config in the pyproject.yaml, currently:
[tool.ruff]
builtins = ["ellipsis"]
extend-exclude = ["xarray_subset_grid/_version.py"]
target-version = "py310"
# Use a longer line length.
line-length = 100
[tool.ruff.lint]
ignore = [
"E402", # module level import not at top of file
"E731", # do not assign a lambda expression, use a def
]
select = [
"F", # Pyflakes
"E", # Pycodestyle
"W",
"TID", # flake8-tidy-imports (absolute imports)
"I", # isort
"UP", # Pyupgrade
]
extend-safe-fixes = [
"TID252", # absolute imports
]
So shouldn't we simply call ruff check --fix (or whatever the incantation is) and leave all the config in the pyproject file?
But in any case -- yes, as for right now, minimal churn, and we can decide to nail down / update the project style requirements in the future.
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.
That is what pre-commit does.
.pre-commit-config.yaml
Outdated
| hooks: | ||
| - id: ruff | ||
| args: ["--fix", "--show-fixes"] | ||
| # - id: ruff-format |
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.
If folks want to adopt ruff format in lieu of black, we should do that ASAP to avoid a lot of churn in the code base as the code grows in size.
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.
see below -- yes, let's use ruff.
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.
Ruff format is one of the ruff lint's that is not used here. It is recommended as a black substitute. None of the selected ruff lints in the project.toml implements ruff format.
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.
Got it -- I added some ruff format config, and ran it, in the reformat branch.
It seems to have done a fine job, with not a lot of disruption.
Can you merge that in to this pre-commit branch and see how it goes?
.pre-commit-config.yaml
Outdated
| # - repo: https://github.com/woodruffw/zizmor-pre-commit | ||
| # rev: v1.6.0 | ||
| # hooks: | ||
| # - id: zizmor |
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'll enable this one after #65 b/c that PR already fixes most if it.
|
Yes, let's stick with ruff -- that's what we've been using, and it currently passes a ruff check (as configured in the pyproject.yaml). |
b79b3f0 to
fa454ca
Compare
|
@ChrisBarker-NOAA the sdist is way too big and, before we publish this on PyPI, let me work on it a little bit to remove all test data from the sdist. Otherwise we risk reaching storage quota with just a few releases. |
4f9b846 to
a79a79a
Compare
|
@ChrisBarker-NOAA this one is ready to go. I'll work on the data and test organization after it. |
|
Thanks! |
|
One question -- blackdoc formats code in docstrings, yes? Doesn't ruff have that as well (at least as an option?) -- though as long as they do the same thing, no harm no foul. |
Yes.
One needs: In the |
Closes #66