Skip to content

Commit 7a4f933

Browse files
authored
Merge pull request #878 from scop/chore/ruff
test(python): switch linting to Ruff
2 parents 3f2ccc9 + 5e95a81 commit 7a4f933

File tree

7 files changed

+30
-57
lines changed

7 files changed

+30
-57
lines changed

.github/renovate.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,20 @@
3939
"versioning": "pep440",
4040
"groupName": "black"
4141
},
42-
{
43-
"matchPackagePatterns": ["(^|/)flake8$"],
44-
"versioning": "pep440",
45-
"groupName": "flake8"
46-
},
4742
{
4843
"matchPackagePatterns": ["(^|/)gitlint$"],
4944
"versioning": "pep440",
5045
"groupName": "gitlint"
5146
},
52-
{
53-
"matchPackagePatterns": ["(^|/)isort$"],
54-
"versioning": "pep440",
55-
"groupName": "isort"
56-
},
5747
{
5848
"matchPackageNames": ["perltidy/perltidy"],
5949
"versioning": "regex:^(?<major>\\d{8})$"
6050
},
51+
{
52+
"matchPackagePatterns": ["(^|/)ruff(-pre-commit)?$"],
53+
"groupName": "ruff",
54+
"versioning": "pep440"
55+
},
6156
{
6257
"matchPackageNames": [
6358
"scop/pre-commit-shfmt",

.pre-commit-config.yaml

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,22 @@ repos:
4141
files: ^completions/_
4242
pass_filenames: false
4343

44-
- repo: https://github.com/psf/black
45-
rev: 23.1.0
44+
- repo: https://github.com/charliermarsh/ruff-pre-commit
45+
rev: v0.0.247
4646
hooks:
47-
- id: black
47+
- id: ruff
4848
types: [text]
4949
files: ^(helpers/python|.+\.py)$
5050
exclude: ^completions/
5151

52-
- repo: https://github.com/PyCQA/flake8
53-
rev: 6.0.0
52+
- repo: https://github.com/psf/black
53+
rev: 23.1.0
5454
hooks:
55-
- id: flake8
56-
args: [--config=test/setup.cfg]
57-
additional_dependencies:
58-
# Splitting dashes and items on separate lines is intentional,
59-
# enables Renovate's pip_requirements manager to update this file.
60-
-
61-
pycodestyle ==2.10.0
62-
-
63-
pyflakes ==3.0.1
64-
-
65-
flake8-bugbear ==23.1.14
55+
- id: black
6656
types: [text]
6757
files: ^(helpers/python|.+\.py)$
6858
exclude: ^completions/
6959

70-
- repo: https://github.com/PyCQA/isort
71-
rev: 5.12.0
72-
hooks:
73-
- id: isort
74-
args: [--filter-files, --settings-path=test/setup.cfg]
75-
7660
- repo: local
7761
hooks:
7862
- id: mypy
@@ -87,13 +71,6 @@ repos:
8771
# Intentionally not run on helpers/python (we support very old versions)
8872
exclude: ^completions/|^test/fixtures/pytest/
8973

90-
- repo: https://github.com/asottile/pyupgrade
91-
rev: v3.1.0
92-
hooks:
93-
- id: pyupgrade
94-
args: [--py36-plus, --keep-percent-format]
95-
exclude: ^completions/
96-
9774
- repo: https://github.com/perltidy/perltidy
9875
rev: "20210717"
9976
hooks:

doc/testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and [pexpect](https://pexpect.readthedocs.io/).
1313

1414
For the Python part, all of it is formatted using
1515
[Black](https://github.com/psf/black), and we also run
16-
[Flake8](https://flake8.pycqa.org/) on it.
16+
[Ruff](https://github.com/charliermarsh/ruff) on it.
1717

1818
## Installing dependencies
1919

helpers/python

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ else:
1111
walker = pkgutil.iter_modules
1212

1313
for mod in walker():
14-
print(mod[1]) # noqa: E211
14+
print(mod[1])

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
[tool.black]
22
line-length = 79
33
target-version = ["py36", "py37", "py38", "py39", "py310"]
4+
5+
[tool.ruff]
6+
line-length = 79
7+
target-version = "py37"
8+
select = ["E", "F", "B"]
9+
ignore = [
10+
"E50", # Black
11+
"E70", # Black
12+
13+
]
14+
fix = true
15+
16+
[tool.ruff.isort]
17+
known-first-party = ["conftest"]
18+
known-third-party = ["pexpect", "pytest"]

test/requirements-dev.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@
44

55
black ==23.1.0
66

7-
flake8 ==6.0.0
8-
pycodestyle ==2.10.0
9-
pyflakes ==3.0.1
10-
flake8-bugbear ==23.1.14
11-
12-
isort ==5.12.0
13-
147
mypy ==0.971
158

169
pre-commit >=2.4.0
10+
11+
ruff ==0.0.247

test/setup.cfg

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,3 @@ python_version = 3.6
99
mypy_path = $MYPY_CONFIG_FILE_DIR/t
1010
show_error_codes = true
1111
enable_error_code = ignore-without-code
12-
13-
[isort]
14-
known_first_party = conftest
15-
known_third_party = pexpect,pytest
16-
profile = black
17-
line_length = 79
18-
19-
[flake8]
20-
extend-ignore = D202,E203,E501

0 commit comments

Comments
 (0)