Skip to content
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

Merged
merged 6 commits into from
Sep 5, 2023
Merged

DM-40628: Switch to Ruff for linting #194

merged 6 commits into from
Sep 5, 2023

Conversation

rra
Copy link
Member

@rra rra commented Sep 5, 2023

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.

rra added 4 commits September 5, 2023 10:52
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.
@rra rra requested a review from jonathansick September 5, 2023 17:56
@rra
Copy link
Member Author

rra commented Sep 5, 2023

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.

rra added 2 commits September 5, 2023 10:59
Our documentation style allows wrapped summary lines longer than a
single line. Disable the corresponding Ruff diagnostic and revert
changes to satisfy that diagnostic.
@rra
Copy link
Member Author

rra commented Sep 5, 2023

Per discussion, excluded the Ruff warning about multiline docstring summary lines and reverted the changes to satisfy that.

@jonathansick
Copy link
Member

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.

@rra rra merged commit d0f7f88 into main Sep 5, 2023
@rra rra deleted the tickets/DM-40628 branch September 5, 2023 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants