-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[py] Use ruff for linting and code formatting #15746
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
base: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍(Review updated until commit 95b5594)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 95b5594
Previous suggestions✅ Suggestions up to commit 95b5594
|
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
User description
💥 What does this PR do?
As discussed here:
#13679 (comment)
This PR replaces the current Python linters (black, isort, docformatter, autoflake, flake8) with ruff:
ruff is a linter and formatter that provides all of the functionality of the old linters, plus:
🔧 Implementation Notes
Previously, we had 2 tox environments:
linting-ci
andlinting
, for use in CI and for local development. This PR consolidates that into a single environment (linting
) that can be used for both. I adjusted theci-python.yaml
GHA workflow to use this.This PR also fixes all of the linting and formatting violations across the codebase that were fixed using the new tooling.
💡 Additional Considerations
Now we should setup ruff to be used hermetically via Bazel. (@p0deje has graciously volunteered to do that work)
🔄 Types of changes
PR Type
Enhancement, Other
Description
Replace multiple Python linters with ruff for linting/formatting
Remove isort, black, autoflake, flake8, docformatter configs and dependencies
Update CI workflow and tox to use ruff exclusively
Apply ruff-based formatting and linting fixes across codebase
Changes walkthrough 📝
4 files
Update CI to use ruff for Python linting
Remove old linter configs, add ruff configuration
Remove old linting environments, add ruff to linting
Switch Python formatting to ruff in script
16 files
Update Python linting instructions to use ruff
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring example to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update docstring examples to use double quotes, ruff formatting
Update warnings and docstring examples, ruff formatting
Update docstring examples to use double quotes, ruff formatting
23 files
Apply ruff formatting to Sphinx config
Apply ruff formatting (add blank lines)
Apply ruff formatting to docstrings and line wrapping
Use consistent double quotes in error messages, ruff formatting
Use consistent double quotes in f-strings, ruff formatting
Apply ruff formatting to docstrings and line wrapping
Apply ruff formatting to docstrings and line wrapping
Apply ruff formatting to docstrings and line wrapping
Apply ruff formatting to docstrings and line wrapping
Remove blank lines, ruff formatting
Remove blank lines, ruff formatting
Use parentheses for long assert statements, ruff formatting
Use single string for JS dict, ruff formatting
Add blank line after docstring, ruff formatting
Add blank line after docstring, ruff formatting
Use string concatenation for long JS, ruff formatting
Use single line for chained calls, ruff formatting
Use string concatenation for long JS, ruff formatting
Add blank line after docstring, ruff formatting
Use line continuation for lambda, ruff formatting
Use parentheses for long assert, ruff formatting
Use single string for assert, ruff formatting
Use string concatenation for long error message, ruff formatting
1 files