-
Notifications
You must be signed in to change notification settings - Fork 18
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
Replace black
with ruff
and add pre-commit
#110
Conversation
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.
LGTM!
Thank you @davidwilby, this does look quite useful. I checked the error message of the CI and we now get many failing docstring checks. Can you 1) address the simpler syntax ones 2) silence more complex issues like missing public function docstrings, so that tests pass? It looks like we can ignore error messages in pyproject.toml with:
|
@tom-andersson I've added a number of rules to ignore and performed the remaining linting of docstrings (the code itself was completely compliant from using The remaining linting failures are for missing docstrings on public methods/functions:
I've had a go at adding a few missing docstrings in 678602a but other than that I don't know enough to write them. One option (which I've used in a couple of places) is to add a Could you add some docstrings or advise on those that are remaining when you get the chance? |
Thanks @davidwilby and sorry for the delay. It's helpful to see where docstrings are missing, so let's keep that behaviour in the linter. I'll add a commit to this PR with the missing docstrings, aiming for this week or the next. |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
An update to the docstrings that need attention:
|
Okay, I think there has to be some statute of limitations on pull requests 😄 so I've opted to ignore these missing docstrings (except one I could actually fill in) and I'll open an issue unless you object @tom-andersson - then we can move on with our lives and merge this after nearly 6 months. |
Let's do it @davidwilby, LGTM. Sorry for blocking - time got away from me w/ my full-time job. So to confirm, developers don't need to run You'll need to sync and re-run, but I think you have permissions to rebase + merge yourself? |
@tom-andersson thanks for the review! I've rebased locally since there were many conflicts. All the tests are passing but I'll give you the opportunity to cast a quick eye over it and check I haven't made any mistakes in resolving the conflicts. |
@@ -824,7 +810,7 @@ def time_slice_variable(self, var, date, delta_t=0): | |||
raise ValueError(f"Unknown variable type {type(var)}") | |||
return var | |||
|
|||
def task_generation( | |||
def task_generation( # noqa: D102 |
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.
Out of curiosity, what is this noqa: D102
? Is this comment flag handled automatically by ruff?
Thanks @davidwilby, took another look and passes a sanity check. I'd rather you removed the changes to the documentation notebooks before merging though (see my review comment). WDYT? |
Hey @tom-andersson et al - just a maintenance-related PR for your perusal, feel free to reject if this isn't your thing.
What this PR does
black
withruff
as the linter of choice, partially because of extra features such as linting docstrings in google-style (which black may do as well, but I haven't been able to find it)pre-commit
and a pre-commit config to run the ruff linter and formatter on a pre-commit hook.CONTRIBUTING.md
detailing the use of these tools.What this PR doesn't do
At the moment the CI check fails since
ruff
is checking all the docstrings, we may be able to soften the docstring rules (configured inpyproject.toml
) to something we agree with (e.g. I don't necessarily think that every module needs a docstring)FYI @nilsleh