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 48468c4

Browse filesBrowse files
cclaussMoLow
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 d40bcdd commit 48468c4
Copy full SHA for 48468c4

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
@@ -1514,22 +1514,22 @@ cpplint: lint-cpp
15141514
$(warning Please use lint-cpp instead of cpplint)
15151515

15161516
.PHONY: lint-py-build
1517-
# python -m pip install flake8
1517+
# python -m pip install ruff
15181518
# Try with '--system' if it fails without; the system may have set '--user'
15191519
lint-py-build:
1520-
$(info Pip installing flake8 linter on $(shell $(PYTHON) --version)...)
1521-
$(PYTHON) -m pip install --upgrade -t tools/pip/site-packages flake8 || \
1522-
$(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages flake8
1520+
$(info Pip installing ruff on $(shell $(PYTHON) --version)...)
1521+
$(PYTHON) -m pip install --upgrade --target tools/pip/site-packages ruff || \
1522+
$(PYTHON) -m pip install --upgrade --system --target tools/pip/site-packages ruff
15231523

15241524
.PHONY: lint-py
1525-
ifneq ("","$(wildcard tools/pip/site-packages/flake8)")
1526-
# Lints the Python code with flake8.
1527-
# Flag the build if there are Python syntax errors or undefined names
1525+
ifneq ("","$(wildcard tools/pip/site-packages/ruff)")
1526+
# Lint the Python code with ruff.
15281527
lint-py:
1529-
PYTHONPATH=tools/pip $(PYTHON) -m flake8 --count --show-source --statistics .
1528+
tools/pip/site-packages/bin/ruff --version
1529+
tools/pip/site-packages/bin/ruff .
15301530
else
15311531
lint-py:
1532-
$(warning Python linting with flake8 is not available)
1532+
$(warning Python linting with ruff is not available)
15331533
$(warning Run 'make lint-py-build')
15341534
endif
15351535

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.