-
Notifications
You must be signed in to change notification settings - Fork 1
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
DM-40628: Switch to Ruff for linting #194
Conversation
Remove some trailing whitespace caught by the new pre-commit hooks.
Let Ruff do its automatic fixes and fix nearly all of the remaining issues. The most controversial change is probably that Ruff by default wants the first line of a docstring to fit on a single line, so some docstrings have been restructured to satisfy this check.
Several list_* mock Kubernetes API functions were using variations of the same pattern to support field and label selectors. Move that code into a helper method so that it can be shared, and clean up the coding style of the function that checks label selectors.
Add a Ruff pre-commit hook and configure it based on the current SQuaRE PyPI library template. Also enable conflict and trailing whitespace checking in the standard pre-commit hooks.
This is mostly mechanical and uninteresting to review, but I wanted to give you a chance to object to the rewording of docstrings to make the first line fit on one line. Our documentation coding style allows multiple lines, but the default Ruff configuration doesn't. I looked at the things it flagged and it seemed straightforward to reword them without much loss, so I took that route, but I don't have strong feelings about it. |
Our documentation style allows wrapped summary lines longer than a single line. Disable the corresponding Ruff diagnostic and revert changes to satisfy that diagnostic.
Per discussion, excluded the Ruff warning about multiline docstring summary lines and reverted the changes to satisfy that. |
The gist of our decision on docstrings is that the parsers are capable of interpreting a sentence of multiple lines as the docstring summary line, so there isn't much practical advantage in adhering to PEP 257/numpydoc's "single line" rule if it means we have to compromise on clarity and formatting to meet a character requirement on that sentence. |
Convert to Ruff for linting instead of isort and flake8, and fix the problems it found that seem legitimate. Add a couple of Safir-specific ignores for exception naming deviations and use of global variables in the logging setup.
Refactor the list methods in the Kubernetes mock to avoid Ruff complexity warnings and share more code. There is one remaining complexity warning that will be fixed in a follow-up PR.
Add pre-commit checks for trailing whitespace and merge conflicts, and fix some trailing whitespace.