-
Notifications
You must be signed in to change notification settings - Fork 166
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
ci: replace Python linter flake8 with ruff #3302
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# https://beta.ruff.rs | ||
name: Lint Python | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
jobs: | ||
lint_python: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: pip install --user ruff | ||
- run: ruff --format=github . |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[tool.ruff] | ||
select = [ | ||
"A", # flake8-builtins | ||
"ARG", # flake8-unused-arguments | ||
"B", # flake8-bugbear | ||
"C4", # flake8-comprehensions | ||
"C90", # McCabe cyclomatic complexity | ||
"E", # pycodestyle | ||
"EM", # flake8-errmsg | ||
"EXE", # flake8-executable | ||
"F", # Pyflakes | ||
"G", # flake8-logging-format | ||
"I", # isort | ||
"ICN", # flake8-import-conventions | ||
"INT", # flake8-gettext | ||
"ISC", # flake8-implicit-str-concat | ||
"PGH", # pygrep-hooks | ||
"PIE", # flake8-pie | ||
"PL", # Pylint | ||
"PT", # flake8-pytest-style | ||
"PYI", # flake8-pyi | ||
"RET", # flake8-return | ||
"RSE", # flake8-raise | ||
"RUF", # Ruff-specific rules | ||
"S", # flake8-bandit | ||
"SIM", # flake8-simplify | ||
"SLF", # flake8-self | ||
"T10", # flake8-debugger | ||
"TCH", # flake8-type-checking | ||
"TID", # flake8-tidy-imports | ||
"W", # pycodestyle | ||
"YTT", # flake8-2020 | ||
] | ||
ignore = [ | ||
"B904", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are this ignores TODOs or forever things? Sometimes useful to document why/how the might be fixed if someone has an interest to try and address them later There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will let others determine if/when they want to reduce the ignore list Rule information is easy to acquire: raise-without-from-inside-except (B904)Derived from the flake8-bugbear linter. Message formats:
|
||
"PLR2004", | ||
"RET505", | ||
"RUF005", | ||
"S110", | ||
"S701" | ||
] | ||
line-length = 223 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guessing this was to get it passing, rather than a preferred line length like the old 250 value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 88 is the preferred value for Python code. The goal here is to set high water marks so that if a contributor wants to go beyond that level they will need to justify their actions in the code reviews of their pull requests. The same is true of |
||
target-version = "py37" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the target is going to stay 3.7 for now, maybe the CI should keep the pinned version that I dropped in the other PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #3301 (comment) Ruff does not run on Python so it changes in similar ways to flake8 but only based on Just like Node.js, Python has a release cycle: https://devguide.python.org/versions Py37 will reach EOL in two months. |
||
|
||
[tool.ruff.mccabe] | ||
max-complexity = 15 | ||
|
||
[tool.ruff.pylint] | ||
max-args = 5 | ||
max-branches = 15 | ||
max-returns = 7 | ||
max-statements = 50 |
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.
I'd suggest copying the filters from https://github.com/nodejs/build/pull/3301/files#diff-14721317565b7c66355f276ec27762054b12f390afd6c35fba85cfaf77d311c7R2, but adding
pyproject.toml
to the listsThere 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.
This is a bad practice when tools are fast.
build git:(ruff) %
time ruff .
Ruff will lint the entire CPython codebase in 0.29 seconds with no cache so we are saving no time by attempting to hide files from the linter and could easily miss faults in code added to this repo in the 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.
It's not about tool speed, it's about not running jobs that can have unrelated job failures on a PR