Skip to content

Commit 11cc3bb

Browse files
authored
Merge pull request #1066 from scop/chore/black-to-ruff
chore: switch Python formatting from `black` to `ruff format`
2 parents cfef85b + a10f2ab commit 11cc3bb

File tree

10 files changed

+42
-39
lines changed

10 files changed

+42
-39
lines changed

.dir-locals.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
;;; For more information see (info "(emacs) Directory Variables")
33

44
((python-mode
5-
(eval add-hook 'before-save-hook 'blacken-buffer nil t))
5+
(mode . ruff-format-on-save))
66
(sh-mode
77
(mode . shfmt-on-save)
88
(shfmt-arguments "-s")

.github/renovate.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@
3939
"commitMessageTopic": "{{depName}}",
4040
"semanticCommitScope": "pre-commit"
4141
},
42-
{
43-
"matchPackagePatterns": ["(^|/)black(-pre-commit-mirror)?$"],
44-
"versioning": "pep440",
45-
"groupName": "black"
46-
},
4742
{
4843
"matchPackagePatterns": ["(^|/)gitlint$"],
4944
"versioning": "pep440",

.pre-commit-config.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ repos:
4949
types: [text]
5050
files: ^(helpers/python|.+\.py)$
5151
exclude: ^completions/
52-
53-
- repo: https://github.com/psf/black-pre-commit-mirror
54-
rev: 23.1.0
55-
hooks:
56-
- id: black
52+
- id: ruff-format
5753
types: [text]
5854
files: ^(helpers/python|.+\.py)$
5955
exclude: ^completions/

doc/testing.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ and [pexpect](https://pexpect.readthedocs.io/).
1111

1212
## Coding style
1313

14-
For the Python part, all of it is formatted using
15-
[Black](https://github.com/psf/black), and we also run
16-
[Ruff](https://github.com/charliermarsh/ruff) on it.
14+
For the Python part, all of it is checked and formatted using
15+
[Ruff](https://docs.astral.sh/ruff/).
1716

1817
## Installing dependencies
1918

pyproject.toml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
[tool.black]
2-
line-length = 79
3-
target-version = ["py36", "py37", "py38", "py39", "py310"]
4-
51
[tool.ruff]
62
line-length = 79
73
target-version = "py37"
84
select = ["E", "F", "B"]
95
ignore = [
10-
"E50", # Black
11-
"E70", # Black
12-
6+
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
7+
# (keep order of ignores here same as ^there for maintainability)
8+
"W191",
9+
"E111",
10+
"E114",
11+
"E117",
12+
"D206",
13+
"D300",
14+
"Q000",
15+
"Q001",
16+
"Q002",
17+
"Q003",
18+
"COM812",
19+
"COM819",
20+
"ISC001",
21+
"ISC002",
22+
"E501",
1323
]
1424
fix = true
1525

test/requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
-r requirements.txt
44

5-
black==23.1.0
65
mypy==1.2.0
76
ruff==0.1.6

test/t/conftest.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -426,20 +426,22 @@ def assert_bash_exec(
426426
)
427427
if want_output is not None:
428428
if output:
429-
assert (
430-
want_output
431-
), 'Unexpected output from "%s": exit status=%s, output="%s"' % (
432-
cmd,
433-
status,
434-
output,
429+
assert want_output, (
430+
'Unexpected output from "%s": exit status=%s, output="%s"'
431+
% (
432+
cmd,
433+
status,
434+
output,
435+
)
435436
)
436437
else:
437-
assert (
438-
not want_output
439-
), 'Expected output from "%s": exit status=%s, output="%s"' % (
440-
cmd,
441-
status,
442-
output,
438+
assert not want_output, (
439+
'Expected output from "%s": exit status=%s, output="%s"'
440+
% (
441+
cmd,
442+
status,
443+
output,
444+
)
443445
)
444446

445447
return output

test/t/test_installpkg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ def test_1(self, completion):
1212
@pytest.mark.complete("installpkg --")
1313
def test_2(self, completion):
1414
assert (
15-
completion == "--ask --infobox --md5sum --menu "
15+
completion
16+
== "--ask --infobox --md5sum --menu "
1617
"--priority --root --tagfile --terse --warn".split()
1718
)
1819

test/t/test_upgradepkg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def test_1(self, completion):
1212
@pytest.mark.complete("upgradepkg --")
1313
def test_2(self, completion):
1414
assert (
15-
completion == "--dry-run --install-new --reinstall "
16-
"--verbose".split()
15+
completion
16+
== "--dry-run --install-new --reinstall --verbose".split()
1717
)
1818

1919
@pytest.mark.complete("upgradepkg ", cwd="slackware/home")

test/t/test_xz.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ def test_1(self, completion):
99
@pytest.mark.complete("xz -d xz/")
1010
def test_2(self, completion):
1111
assert (
12-
completion == "a/ bashcomp.lzma bashcomp.tar.xz "
13-
"bashcomp.tlz bashcomp.xz".split()
12+
completion
13+
== "a/ bashcomp.lzma bashcomp.tar.xz bashcomp.tlz "
14+
"bashcomp.xz".split()
1415
)
1516

1617
@pytest.mark.complete("xz xz/")

0 commit comments

Comments
 (0)