Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 78c0824

Browse filesBrowse files
cclausstargos
authored andcommitted
build: replace Python linter flake8 with ruff
PR-URL: #47519 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent 7ca416a commit 78c0824
Copy full SHA for 78c0824

File tree

Expand file treeCollapse file tree

5 files changed

+58
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+58
-14
lines changed
Open diff view settings
Collapse file

‎.flake8‎

Copy file name to clipboardExpand all lines: .flake8
-3Lines changed: 0 additions & 3 deletions
This file was deleted.
Collapse file

‎.github/workflows/linters.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/linters.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
run: npx envinfo
130130
- name: Lint Python
131131
run: |
132-
make lint-py-build || true
132+
make lint-py-build
133133
make lint-py
134134
lint-yaml:
135135
if: github.event.pull_request.draft == false
Collapse file

‎.gitignore‎

Copy file name to clipboardExpand all lines: .gitignore
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
!.eslintignore
1515
!.eslintrc.js
1616
!.eslintrc.yaml
17-
!.flake8
1817
!.gitattributes
1918
!.github
2019
!.gitignore
Collapse file

‎Makefile‎

Copy file name to clipboardExpand all lines: Makefile
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,22 +1489,22 @@ cpplint: lint-cpp
14891489
$(warning Please use lint-cpp instead of cpplint)
14901490

14911491
.PHONY: lint-py-build
1492-
# python -m pip install flake8
1492+
# python -m pip install ruff
14931493
# Try with '--system' if it fails without; the system may have set '--user'
14941494
lint-py-build:
1495-
$(info Pip installing flake8 linter on $(shell $(PYTHON) --version)...)
1496-
$(PYTHON) -m pip install --upgrade -t tools/pip/site-packages flake8 || \
1497-
$(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages flake8
1495+
$(info Pip installing ruff on $(shell $(PYTHON) --version)...)
1496+
$(PYTHON) -m pip install --upgrade --target tools/pip/site-packages ruff || \
1497+
$(PYTHON) -m pip install --upgrade --system --target tools/pip/site-packages ruff
14981498

14991499
.PHONY: lint-py
1500-
ifneq ("","$(wildcard tools/pip/site-packages/flake8)")
1501-
# Lints the Python code with flake8.
1502-
# Flag the build if there are Python syntax errors or undefined names
1500+
ifneq ("","$(wildcard tools/pip/site-packages/ruff)")
1501+
# Lint the Python code with ruff.
15031502
lint-py:
1504-
PYTHONPATH=tools/pip $(PYTHON) -m flake8 --count --show-source --statistics .
1503+
tools/pip/site-packages/bin/ruff --version
1504+
tools/pip/site-packages/bin/ruff .
15051505
else
15061506
lint-py:
1507-
$(warning Python linting with flake8 is not available)
1507+
$(warning Python linting with ruff is not available)
15081508
$(warning Run 'make lint-py-build')
15091509
endif
15101510

Collapse file

‎pyproject.toml‎

Copy file name to clipboard
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[tool.ruff]
2+
select = [
3+
"C90", # McCabe cyclomatic complexity
4+
"E", # pycodestyle
5+
"F", # Pyflakes
6+
"ICN", # flake8-import-conventions
7+
"INT", # flake8-gettext
8+
"PLC", # Pylint conventions
9+
"PLE", # Pylint errors
10+
"PLR09", # Pylint refactoring: max-args, max-branches, max returns, max-statements
11+
"PYI", # flake8-pyi
12+
"RSE", # flake8-raise
13+
"RUF", # Ruff-specific rules
14+
"T10", # flake8-debugger
15+
"TCH", # flake8-type-checking
16+
"TID", # flake8-tidy-imports
17+
"W", # pycodestyle
18+
"YTT", # flake8-2020
19+
]
20+
exclude = [
21+
"deps",
22+
"tools/inspector_protocol",
23+
]
24+
ignore = [
25+
"E401",
26+
"E402",
27+
"E7",
28+
"PLC1901",
29+
"RUF005",
30+
"RUF100",
31+
]
32+
line-length = 172
33+
target-version = "py37"
34+
35+
[tool.ruff.mccabe]
36+
max-complexity = 100
37+
38+
[tool.ruff.per-file-ignores]
39+
"tools/checkimports.py" = ["W605"]
40+
"tools/gyp/pylib/gyp/xcodeproj_file.py" = ["PLE0101"]
41+
"tools/icu/shrink-icu-src.py" = ["W605"]
42+
"tools/mkssldef.py" = ["W605"]
43+
44+
[tool.ruff.pylint]
45+
max-args = 12
46+
max-branches = 110
47+
max-returns = 12
48+
max-statements = 289

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.