Skip to content

Commit f0c2854

Browse files
committed
CI: Move to ruff for lint
1 parent 0429e21 commit f0c2854

3 files changed

Lines changed: 128 additions & 24 deletions

File tree

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: '🔎 Python Linter'
4+
name: "🔎 Python Linter"
55

66
on:
77
push:
8-
branches: [ "main" ]
8+
branches: ["main"]
99
pull_request:
10-
branches: [ "main" ]
10+
branches: ["main"]
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615
strategy:
1716
fail-fast: false
1817

1918
steps:
20-
- name: '⏳ Checkout repository'
21-
uses: actions/checkout@v3
22-
23-
- name: '🐍 Set up Python'
24-
uses: actions/setup-python@v4
25-
with:
26-
cache: 'pip'
27-
python-version: "3.10"
28-
29-
- name: '🛠 Install dependencies'
30-
run: |
31-
pip install -r .github/workflows/requirements.txt
32-
flake8 --version
33-
pytest --version
34-
35-
- name: '😾 Lint with flake8'
36-
run: |
37-
flake8 --count --ignore=C901,E221,E203 --select=E9,F63,F7,F82 --exclude=manifest.py --show-source --statistics lib/
38-
flake8 --count --ignore=C901,E221,E203 --max-complexity=15 --max-line-length=120 --exclude=manifest.py --statistics lib/
19+
- name: "⏳ Checkout repository"
20+
uses: actions/checkout@v3
21+
22+
- name: "🐍 Set up Python"
23+
uses: actions/setup-python@v4
24+
with:
25+
cache: "pip"
26+
python-version: "3.10"
27+
28+
- name: "🛠 Install dependencies"
29+
run: |
30+
pip install -r .github/workflows/requirements.txt
31+
ruff --version
32+
pytest --version
33+
34+
- name: "😾 Lint with ruff"
35+
run: ruff check

.github/workflows/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22

33

4-
flake8==6.0.0
4+
ruff==0.11.6
55
pytest==7.4.0

pyproject.toml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
[tool.isort]
2+
profile = "black"
3+
4+
[tool.ruff]
5+
line-length = 99
6+
target-version = "py37"
7+
8+
[tool.ruff.lint]
9+
select = [
10+
"ASYNC", # flake8-comprehensions
11+
"C4", # flake8-comprehensions
12+
"C90", # McCabe cyclomatic complexity
13+
"DTZ", # flake8-datetimez
14+
"E", # pycodestyle
15+
"EXE", # flake8-executable
16+
"F", # Pyflakes
17+
"G", # flake8-logging-format
18+
"ICN", # flake8-import-conventions
19+
"INT", # flake8-gettext
20+
"ISC", # flake8-implicit-str-concat
21+
"PGH", # pygrep-hooks
22+
"PIE", # flake8-pie
23+
"PL", # Pylint
24+
"PYI", # flake8-pyi
25+
"RSE", # flake8-raise
26+
"RUF", # Ruff-specific rules
27+
"T10", # flake8-debugger
28+
"TCH", # flake8-type-checking
29+
"W", # pycodestyle
30+
"YTT", # flake8-2020
31+
# "A", # flake8-builtins
32+
# "ANN", # flake8-annotations
33+
# "ARG", # flake8-unused-arguments
34+
# "B", # flake8-bugbear
35+
# "BLE", # flake8-blind-except
36+
# "COM", # flake8-commas
37+
# "D", # pydocstyle
38+
# "DJ", # flake8-django
39+
# "EM", # flake8-errmsg
40+
# "ERA", # eradicate
41+
# "FBT", # flake8-boolean-trap
42+
# "I", # isort
43+
# "INP", # flake8-no-pep420
44+
# "N", # pep8-naming
45+
# "NPY", # NumPy-specific rules
46+
# "PD", # pandas-vet
47+
# "PT", # flake8-pytest-style
48+
# "PTH", # flake8-use-pathlib
49+
# "Q", # flake8-quotes
50+
# "RET", # flake8-return
51+
# "S", # flake8-bandit
52+
# "SIM", # flake8-simplify
53+
# "SLF", # flake8-self
54+
# "T20", # flake8-print
55+
# "TID", # flake8-tidy-imports
56+
# "TRY", # tryceratops
57+
# "UP", # pyupgrade
58+
]
59+
ignore = [
60+
"E722",
61+
"E741", # 'l' is currently widely used
62+
"F401",
63+
"F403",
64+
"F405",
65+
"E501", # line length, recommended to disable
66+
"ISC001",
67+
"ISC003", # micropython does not support implicit concatenation of f-strings
68+
"PIE810", # micropython does not support passing tuples to .startswith or .endswith
69+
"PLC1901",
70+
"PLR1704", # sometimes desirable to redefine an argument to save code size
71+
"PLR1714",
72+
"PLR5501",
73+
"PLW0602",
74+
"PLW0603",
75+
"PLW2901",
76+
"RUF012",
77+
"RUF100",
78+
"SIM101",
79+
"W191", # tab-indent, redundant when using formatter
80+
]
81+
82+
[tool.ruff.lint.mccabe]
83+
max-complexity = 61
84+
85+
[tool.ruff.lint.pylint]
86+
allow-magic-value-types = ["bytes", "int", "str"]
87+
max-args = 14
88+
max-branches = 58
89+
max-returns = 13
90+
max-statements = 166
91+
92+
[tool.ruff.lint.per-file-ignores]
93+
# manifest.py files are evaluated with some global names pre-defined
94+
"**/manifest.py" = ["F821"]
95+
96+
[tool.ruff.format]
97+
# Like Black, use double quotes for strings.
98+
quote-style = "double"
99+
100+
# Like Black, indent with spaces, rather than tabs.
101+
indent-style = "space"
102+
103+
# Like Black, respect magic trailing commas.
104+
skip-magic-trailing-comma = false
105+
106+
# Like Black, automatically detect the appropriate line ending.
107+
line-ending = "auto"

0 commit comments

Comments
 (0)