-
Notifications
You must be signed in to change notification settings - Fork 19
Python linting with Ruff #909
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
2a4bcea
to
93b3b3e
Compare
[Rebased on top of |
|
||
def generator(module_class_name, fq_interface_name, fq_impl_names, help_names): | ||
"""Generates the text for a module support file.""" | ||
"""Generate the text for a module support file.""" |
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.
Is there a reason the prescriptive second person form (generate), rather than the descriptive third person form (generates)? Admittedly I got this from writing javadoc comments many years ago, rather than any Python standard, but I feel it makes more sense to 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.
It comes from D401 First line of docstring should be in imperative mood
. We could ignore this rule if preferred?
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.
No, I'll try to follow that rule in 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.
Big, but not complex. I can only apologize for the amount of trailing whitespace.
Python linting with Ruff
Fixes #891
This PR adds ruff for Python linting, which is used widely by the community.
Useful info
ruff check
we can see the current issues.ruff check --fix
we can get ruff to automatically fix many issues that are guaranteed not to break things.ruff check --fix --unsafe-fixes
option but it should be used with care.ruff format
but it's quite opinionated so would likely completely reformat everything.ruff.toml
contains the configuration, including any rules to ignore.test/era5_topaz4_test_data.py
because this is an enormous file.ruff check --statistics
gave the following:To get things to work, I applied ruff fixes, made code changes, and ignored rules that'd require more work to satisfy. The ignored rules are:
shell=True
I also applied per-file ignores to some of the code generation code for use of assertions as they'd need some refactoring to remove them and retain checks.
Checklist
ruff check
pass by fixing issues and ignoring rules, as appropriate.