-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[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
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-ciandlinting, 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.yamlGHA 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 lintingRemove old linter configs, add ruff configurationRemove old linting environments, add ruff to lintingSwitch Python formatting to ruff in script16 files
Update Python linting instructions to use ruffUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring example to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate docstring examples to use double quotes, ruff formattingUpdate warnings and docstring examples, ruff formattingUpdate docstring examples to use double quotes, ruff formatting23 files
Apply ruff formatting to Sphinx configApply ruff formatting (add blank lines)Apply ruff formatting to docstrings and line wrappingUse consistent double quotes in error messages, ruff formattingUse consistent double quotes in f-strings, ruff formattingApply ruff formatting to docstrings and line wrappingApply ruff formatting to docstrings and line wrappingApply ruff formatting to docstrings and line wrappingApply ruff formatting to docstrings and line wrappingRemove blank lines, ruff formattingRemove blank lines, ruff formattingUse parentheses for long assert statements, ruff formattingUse single string for JS dict, ruff formattingAdd blank line after docstring, ruff formattingAdd blank line after docstring, ruff formattingUse string concatenation for long JS, ruff formattingUse single line for chained calls, ruff formattingUse string concatenation for long JS, ruff formattingAdd blank line after docstring, ruff formattingUse line continuation for lambda, ruff formattingUse parentheses for long assert, ruff formattingUse single string for assert, ruff formattingUse string concatenation for long error message, ruff formatting1 files