Skip to content

Commit d45b633

Browse files
committed
Use ruff format instead of black/isort
1 parent 50f7a4e commit d45b633

File tree

10 files changed

+19
-29
lines changed

10 files changed

+19
-29
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,11 @@ repos:
3232
entry: ruff check
3333
language: system
3434
types: [python]
35-
- repo: https://github.com/PyCQA/isort
36-
rev: 5.12.0
37-
hooks:
38-
- id: isort
39-
args:
40-
# https://github.com/pre-commit/mirrors-isort/issues/9#issuecomment-624404082
41-
- --filter-files
42-
- repo: https://github.com/psf/black
43-
rev: 22.10.0
44-
hooks:
45-
- id: black
46-
language_version: python3
35+
- id: ruff-format
36+
name: ruff
37+
entry: ruff format --check --diff
38+
language: system
39+
types: [python]
4740
- repo: https://github.com/pre-commit/mirrors-mypy
4841
rev: v1.4.1
4942
hooks:

test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def setup_ansible_config(tmpdir, name, host, user, port, key):
7272
tmpdir.join("inventory").write("[testgroup]\n" + " ".join(items) + "\n")
7373
tmpdir.mkdir("host_vars").join(name).write(ANSIBLE_HOSTVARS)
7474
tmpdir.mkdir("group_vars").join("testgroup").write(
75-
"---\n" "myhostvar: should_be_overriden\n" "mygroupvar: qux\n"
75+
"---\nmyhostvar: should_be_overriden\nmygroupvar: qux\n"
7676
)
7777
vault_password_file = tmpdir.join("vault-pass.txt")
7878
vault_password_file.write("polichinelle\n")

test/test_backends.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_encoding(host):
9696
b"Aucun fichier ou dossier de ce type\n"
9797
)
9898
assert cmd.stderr == (
99-
"ls: impossible d'accéder à '/é': " "Aucun fichier ou dossier de ce type\n"
99+
"ls: impossible d'accéder à '/é': Aucun fichier ou dossier de ce type\n"
100100
)
101101

102102

@@ -415,7 +415,7 @@ def test_ansible_config():
415415
# test testinfra use ANSIBLE_CONFIG
416416
tmp = tempfile.NamedTemporaryFile
417417
with tmp(suffix=".cfg") as cfg, tmp() as inventory:
418-
cfg.write(b"[defaults]\n" b"inventory=" + inventory.name.encode() + b"\n")
418+
cfg.write(b"[defaults]\ninventory=" + inventory.name.encode() + b"\n")
419419
cfg.flush()
420420
inventory.write(b"h\n")
421421
inventory.flush()

test/test_modules.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def test_ansible_module(host):
375375
except host.ansible.AnsibleException as exc:
376376
assert exc.result["rc"] == 2
377377
# notez que the debian bookworm container is set to LANG=fr_FR
378-
assert exc.result["msg"] == ("[Errno 2] Aucun fichier ou dossier " "de ce type")
378+
assert exc.result["msg"] == ("[Errno 2] Aucun fichier ou dossier de ce type")
379379

380380
result = host.ansible("command", "echo foo", check=False)
381381
assert result["stdout"] == "foo"
@@ -622,12 +622,9 @@ def test_ip6tables(host):
622622
try:
623623
v6_rules = host.iptables.rules(version=6)
624624
except AssertionError as exc_info:
625-
if (
626-
"Perhaps ip6tables or your kernel needs to "
627-
"be upgraded" in exc_info.args[0]
628-
):
625+
if "Perhaps ip6tables or your kernel needs to be upgraded" in exc_info.args[0]:
629626
pytest.skip(
630-
f"IPV6 does not seem to be enabled on the docker host" f"\n{exc_info}"
627+
f"IPV6 does not seem to be enabled on the docker host\n{exc_info}"
631628
)
632629
else:
633630
raise

testinfra/backend/lxc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any):
2525
def run(self, command: str, *args: str, **kwargs: Any) -> base.CommandResult:
2626
cmd = self.get_command(command, *args)
2727
out = self.run_local(
28-
"lxc exec %s --mode=non-interactive -- " "/bin/sh -c %s", self.name, cmd
28+
"lxc exec %s --mode=non-interactive -- /bin/sh -c %s", self.name, cmd
2929
)
3030
out.command = self.encode(cmd)
3131
return out

testinfra/backend/salt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def run_salt(self, func: str, args: Any = None) -> Any:
5151
out = self.client.cmd(self.host, func, args or [])
5252
if self.host not in out:
5353
raise RuntimeError(
54-
f"Error while running {func}({args}): {out}. " "Minion not connected ?"
54+
f"Error while running {func}({args}): {out}. Minion not connected ?"
5555
)
5656
return out[self.host]
5757

testinfra/modules/ansible.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def need_ansible(func):
3838
def wrapper(self, *args, **kwargs):
3939
if not self._host.backend.HAS_RUN_ANSIBLE:
4040
raise RuntimeError(
41-
"Ansible module is only available with ansible " "connection backend"
41+
"Ansible module is only available with ansible connection backend"
4242
)
4343
return func(self, *args, **kwargs)
4444

testinfra/modules/process.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def filter(self, **filters):
8282
if str(attrs[key]) != str(value):
8383
break
8484
else:
85-
attrs[
86-
"_get_process_attribute_by_pid"
87-
] = self._get_process_attribute_by_pid
85+
attrs["_get_process_attribute_by_pid"] = (
86+
self._get_process_attribute_by_pid
87+
)
8888
match.append(_Process(attrs))
8989
return match
9090

testinfra/modules/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def gids(self):
232232
def groups(self):
233233
"""Return the list of user local group names"""
234234
local_groups = self.check_output(
235-
'net user %s | findstr /B /C:"Local ' 'Group Memberships"', self.name
235+
'net user %s | findstr /B /C:"Local Group Memberships"', self.name
236236
)
237237
local_groups = local_groups.split()[3:]
238238
return [g.replace("*", "") for g in local_groups]

testinfra/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def report(self) -> int:
162162

163163
out = sys.stdout.buffer
164164
out.write(
165-
(b"TESTINFRA %s - %d passed, %d failed, %d skipped in %.2f " b"seconds\n")
165+
(b"TESTINFRA %s - %d passed, %d failed, %d skipped in %.2f seconds\n")
166166
% (
167167
status,
168168
self.passed,

0 commit comments

Comments
 (0)