Skip to content

Commit c37af28

Browse files
authored
Merge pull request #532 from powerapi-ng/ci/ruff-linter
ci: Add `ruff` linter
2 parents e650987 + bee18af commit c37af28

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@ jobs:
3232
run: |
3333
uv sync --extra everything --dev
3434
35-
- name: Lint with flake8
35+
- name: Run flake8
3636
run: |
3737
uv run flake8 --count --show-source --statistics src/ tests/
3838
39-
- name: Static code analysis with pylint
39+
- name: Run pylint
4040
run: |
4141
uv run pylint src/ tests/
4242
43-
- name: Test with pytest
43+
- name: Run ruff
44+
run: |
45+
uv run ruff check --output-format=github src/ tests/
46+
47+
- name: Run unit tests with coverage
4448
run: |
4549
uv run pytest --cov=powerapi --cov-report=term --cov-report=xml tests/unit
4650

.ruff.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
target-version = "py310" # should match minimal python version of PowerAPI
2+
3+
[lint]
4+
select = [
5+
"F", # pyflakes
6+
"E", # pycodestyle errors
7+
"W", # pycodestyle warnings
8+
"B", # flake8-bugbear
9+
"G", # flake8-logging-format
10+
"PT", # flake8-pytest-style
11+
"UP", # pyupgrade
12+
"ERA", # eradicate
13+
"RUF", # ruff
14+
]
15+
16+
ignore = [
17+
"E501", # line too long
18+
19+
"UP006", # non-pep585-annotation
20+
"UP007", # non-pep604-annotation-union
21+
"UP015", # redundant-open-modes
22+
"UP031", # printf-string-formatting
23+
"UP035", # deprecated-import
24+
"B006", # mutable-argument-default
25+
"B008", # function-call-in-default-argument
26+
"F401", # unused-import
27+
"ERA001", # commented-out-code
28+
"G003", # logging-string-concat
29+
"G004", # logging-f-string
30+
"RUF005", # collection-literal-concatenation
31+
"RUF013", # implicit-optional
32+
"RUF015", # unnecessary-iterable-allocation-for-first-element
33+
34+
"UP026", # deprecated-mock-import
35+
"B005", # strip-with-multi-characters
36+
"B010", # set-attr-with-constant
37+
"B011", # assert-false
38+
"B017", # assert-raises-exception
39+
"B905", # zip-without-explicit-strict
40+
"E721", # type-comparison
41+
"PT001", # pytest-fixture-incorrect-parentheses-style
42+
"PT011", # pytest-raises-too-broad
43+
"PT012", # pytest-raises-with-multiple-statements
44+
"PT015", # pytest-assert-always-false
45+
"PT022", # pytest-useless-yield-fixture
46+
]

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ docs = [
6262

6363
lint = [
6464
"flake8 >= 3.9.2",
65-
"pylint >= 2.16.0"
65+
"pylint >= 2.16.0",
66+
"ruff >= 0.9.6"
6667
]
6768

6869
dev = [

0 commit comments

Comments
 (0)