Skip to content

Commit 3d68ff7

Browse files
authored
Merge pull request #4015 from mulkieran/replace-linters-and-formatters-with-ruff
Replace linters and formatters with ruff
2 parents a404a76 + 9f0a3be commit 3d68ff7

16 files changed

Lines changed: 67 additions & 162 deletions

File tree

.githooks/pre-commit

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ make fmt-ci &&
1313
make tmtlint &&
1414
make check-typos || exit 1
1515

16-
export PYTHONPATH=$PWD/tests/client-dbus/src
17-
1816
cd tests/client-dbus && make fmt-ci && make lint || exit 1

.github/workflows/main.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
- name: Install dependencies for Fedora
4545
run: >
4646
dnf install -y
47-
black
4847
clang
4948
curl
5049
cryptsetup-devel
@@ -53,7 +52,6 @@ jobs:
5352
libblkid-devel
5453
make
5554
ncurses
56-
python3-isort
5755
systemd-devel
5856
- uses: dtolnay/rust-toolchain@master
5957
with:

.github/workflows/support.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
include:
4040
- dependencies: >
4141
libatomic
42-
pylint
4342
python3-dbus-client-gen
4443
python3-dbus-python-client-gen
4544
python3-justbytes
@@ -48,11 +47,10 @@ jobs:
4847
python3-semantic_version
4948
python3-setuptools
5049
python3-tenacity
51-
task: >
52-
PATH=${PATH}:/github/home/.local/bin
53-
PYTHONPATH=./src make -f Makefile lint
50+
ruff
51+
task: PATH=${PATH}:/github/home/.local/bin make -f Makefile lint
5452
working-directory: ./tests/client-dbus
55-
- dependencies: black python3-isort
53+
- dependencies: ruff
5654
task: make -f Makefile fmt-ci
5755
working-directory: ./tests/client-dbus
5856
- dependencies: yamllint tmt

tests/client-dbus/.isort.cfg

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/client-dbus/Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ UNITTEST_OPTS = --verbose
22

33
.PHONY: lint
44
lint:
5-
pylint src/stratisd_client_dbus --ignore=_introspect.py
6-
pylint tests --disable=R0801
5+
ruff check
76
pyright
87

98
.PHONY: startup-tests
@@ -20,13 +19,13 @@ extend-tests:
2019

2120
.PHONY: fmt
2221
fmt:
23-
isort src tests
24-
black .
22+
ruff check --fix --select I
23+
ruff format
2524

2625
.PHONY: fmt-ci
2726
fmt-ci:
28-
isort --diff --check-only src tests
29-
black . --check
27+
ruff check --select I
28+
ruff format --check
3029

3130
.PHONY: tang-tests
3231
tang-tests:

tests/client-dbus/pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[tool.ruff]
2+
target-version = "py312"
3+
line-length = 88
4+
5+
[tool.ruff.lint]
6+
select = ["PL"]
7+
8+
[tool.ruff.lint.isort]
9+
known-first-party = ["dbus_client_gen", "dbus_python_client_gen"]
10+
split-on-trailing-comma = false
11+
12+
[tool.ruff.format]
13+
skip-magic-trailing-comma = true

tests/client-dbus/src/stratisd_client_dbus/_connection.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class Bus:
2626
Our bus.
2727
"""
2828

29-
# pylint: disable=too-few-public-methods
30-
3129
_BUS = None
3230

3331
@staticmethod

tests/client-dbus/tests/misc/test_predict.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _call_predict_usage_pool(
5858
if command.returncode != 0:
5959
raise RuntimeError(
6060
f"Invocation of {_STRATIS_PREDICT_USAGE} returned an error: "
61-
f"{command.returncode,}, {errs}"
61+
f"{command.returncode}, {errs}"
6262
)
6363
prediction = json.loads(outs)
6464

@@ -112,10 +112,7 @@ def test_prediction(self):
112112
encrypted, device_sizes, fs_sizes=None, overprovision=overprovisioned
113113
)
114114
pool_result_post = _call_predict_usage_pool(
115-
encrypted,
116-
device_sizes,
117-
fs_sizes=fs_sizes,
118-
overprovision=overprovisioned,
115+
encrypted, device_sizes, fs_sizes=fs_sizes, overprovision=overprovisioned
119116
)
120117

121118
filesystem_result = _call_predict_usage_filesystem(

tests/client-dbus/tests/udev/_utils.py

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@ def random_string(length):
7373
:param length: Length of random part of string
7474
:return: String
7575
"""
76-
return f'stratis_{"".join(random.choice(string.ascii_uppercase) for _ in range(length))}'
76+
return f"stratis_{''.join(random.choice(string.ascii_uppercase) for _ in range(length))}"
7777

7878

79-
# pylint: disable=too-many-statements
80-
def create_pool(
79+
def create_pool( # noqa: PLR0915
8180
name, devices, *, key_description=None, clevis_info=None, overprovision=True
8281
):
8382
"""
@@ -119,11 +118,7 @@ def create_legacy_pool():
119118
else:
120119
cmdline.extend(["--thumbprint", thp])
121120

122-
with subprocess.Popen(
123-
cmdline,
124-
text=True,
125-
stdin=subprocess.PIPE,
126-
) as process:
121+
with subprocess.Popen(cmdline, text=True, stdin=subprocess.PIPE) as process:
127122
process.stdin.write( # pyright: ignore [reportOptionalMemberAccess]
128123
f"Yes{os.linesep}"
129124
)
@@ -137,7 +132,7 @@ def create_legacy_pool():
137132
newly_created = True
138133

139134
i = 0
140-
while get_pools(name) == [] and i < 5:
135+
while get_pools(name) == [] and i < 5: # noqa PLR2004
141136
i += 1
142137
time.sleep(1)
143138
(pool_object_path, _) = next(iter(get_pools(name)))
@@ -165,13 +160,10 @@ def create_v2_pool():
165160
dbus_slot = (True, slot)
166161

167162
if pin == "tang":
168-
(pin, config) = (
169-
"tang",
170-
json.dumps(
171-
{"url": tang_url, "stratis:tang:trust_url": True}
172-
if thp is None
173-
else {"url": tang_url, "thp": thp}
174-
),
163+
config = json.dumps(
164+
{"url": tang_url, "stratis:tang:trust_url": True}
165+
if thp is None
166+
else {"url": tang_url, "thp": thp}
175167
)
176168
else:
177169
raise RuntimeError(
@@ -350,8 +342,8 @@ def wait_for_udev(fs_type, expected_paths):
350342

351343
except RetryError as err:
352344
raise RuntimeError(
353-
f'Found unexpected devnodes: expected devnodes: {", ".join(expected_devnodes)} '
354-
f'!= found_devnodes: {", ".join(err.last_attempt.result())}'
345+
f"Found unexpected devnodes: expected devnodes: {', '.join(expected_devnodes)} "
346+
f"!= found_devnodes: {', '.join(err.last_attempt.result())}"
355347
) from err
356348

357349

@@ -389,9 +381,8 @@ def start_service(self):
389381
if next(processes("stratisd"), None) is not None:
390382
raise RuntimeError("A stratisd process is already running")
391383

392-
service = subprocess.Popen( # pylint: disable=consider-using-with
393-
[x for x in _STRATISD.split(" ") if x != ""],
394-
text=True,
384+
service = subprocess.Popen(
385+
[x for x in _STRATISD.split(" ") if x != ""], text=True
395386
)
396387

397388
try:
@@ -462,10 +453,7 @@ def __enter__(self):
462453
with open(temp_file.name, "r", encoding="utf-8") as fd_for_dbus:
463454
(_, return_code, message) = Manager.Methods.SetKey(
464455
get_object(TOP_OBJECT),
465-
{
466-
"key_desc": key_desc,
467-
"key_fd": fd_for_dbus.fileno(),
468-
},
456+
{"key_desc": key_desc, "key_fd": fd_for_dbus.fileno()},
469457
)
470458

471459
if return_code != StratisdErrors.OK:

tests/client-dbus/tests/udev/test_dump.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,4 @@ def test_only_pool(self):
9999
result = _call_stratis_dumpmetadata(
100100
devnodes[2], print_bytes=True, only="pool"
101101
)
102-
self.assertGreater(
103-
len(json.loads(result)),
104-
0,
105-
)
102+
self.assertGreater(len(json.loads(result)), 0)

0 commit comments

Comments
 (0)