Skip to content

Commit b1dc723

Browse files
DonDebonairFizzadar
authored andcommitted
chore: reformat with ruff
1 parent 7de34b7 commit b1dc723

File tree

22 files changed

+76
-77
lines changed

22 files changed

+76
-77
lines changed

src/pyinfra/api/operation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def __repr__(self) -> str:
7575
f"commands={len(self._commands)}{retry_info})"
7676
)
7777
return (
78-
"OperationMeta(executed=False, "
79-
f"maybeChange={self._maybe_is_change}, hash={self._hash})"
78+
f"OperationMeta(executed=False, maybeChange={self._maybe_is_change}, hash={self._hash})"
8079
)
8180

8281
# Completion & status checks

src/pyinfra/api/util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ def get_caller_frameinfo(frame_offset: int = 0):
110110

111111

112112
def get_operation_order_from_stack(state: "State"):
113-
114113
stack_items = list(reversed(stack()))
115114

116115
i = 0

src/pyinfra/connectors/chroot.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ def make_names_data(name: Optional[str] = None):
4747

4848
show_warning()
4949

50-
yield "@chroot/{0}".format(name), {
51-
"chroot_directory": "/{0}".format(name.lstrip("/")),
52-
}, ["@chroot"]
50+
yield (
51+
"@chroot/{0}".format(name),
52+
{
53+
"chroot_directory": "/{0}".format(name.lstrip("/")),
54+
},
55+
["@chroot"],
56+
)
5357

5458
@override
5559
def connect(self) -> None:

src/pyinfra/connectors/docker.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ def _start_docker_image(self, image_name):
112112
return local.shell(
113113
f"{self.docker_cmd} run -d {image_name} tail -f /dev/null",
114114
splitlines=True,
115-
)[
116-
-1
117-
] # last line is the container ID
115+
)[-1] # last line is the container ID
118116
except PyinfraError as e:
119117
raise ConnectError(e.args[0])
120118

src/pyinfra/connectors/ssh.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def _connect(self) -> None:
275275

276276
logger.warning("WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!")
277277
logger.warning(
278-
("Someone could be eavesdropping on you right now " "(man-in-the-middle attack)!"),
278+
("Someone could be eavesdropping on you right now (man-in-the-middle attack)!"),
279279
)
280280
logger.warning("If this is expected, you can remove the bad key using:")
281281
logger.warning(f" ssh-keygen -R {remove_entry}")
@@ -391,7 +391,6 @@ def get_file_transfer_connection(self) -> FileTransferClient | None:
391391
),
392392
)
393393
except SSHException as e:
394-
395394
raise ConnectError(
396395
(
397396
"Unable to establish SFTP connection. Check that the SFTP subsystem "

src/pyinfra/facts/freebsd.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ def command(self, srvname: str, jail: Optional[str] = None) -> StringCommand:
3232
jail = ""
3333

3434
return make_formatted_string_command(
35-
(
36-
"service -j {0} {1} status > /dev/null 2>&1; "
37-
"if [ $? -eq 0 ]; then "
38-
"echo running; "
39-
"fi"
40-
),
35+
("service -j {0} {1} status > /dev/null 2>&1; if [ $? -eq 0 ]; then echo running; fi"),
4136
QuoteString(jail),
4237
QuoteString(srvname),
4338
)

src/pyinfra/operations/choco.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,8 @@ def install():
5454
Install ``choco`` (Chocolatey).
5555
"""
5656

57-
yield "Set-ExecutionPolicy Bypass -Scope Process -Force ;" "iex ((New-Object System.Net.WebClient).DownloadString" '("https://chocolatey.org/install.ps1"))' # noqa
57+
yield (
58+
"Set-ExecutionPolicy Bypass -Scope Process -Force ;"
59+
"iex ((New-Object System.Net.WebClient).DownloadString"
60+
'("https://chocolatey.org/install.ps1"))'
61+
) # noqa

src/pyinfra/operations/docker.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def volume(volume: str, driver: str = "", labels: list[str] | None = None, prese
194194
existent_volume = host.get_fact(DockerVolume, object_id=volume)
195195

196196
if present:
197-
198197
if existent_volume:
199198
host.noop("Volume already exists!")
200199
return

src/pyinfra/operations/files.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,7 @@ def download(
260260

261261
if md5sum:
262262
yield make_formatted_string_command(
263-
(
264-
"(( md5sum {0} 2> /dev/null || md5 {0} ) | grep {1}) "
265-
"|| ( echo {2} && exit 1 )"
266-
),
263+
("(( md5sum {0} 2> /dev/null || md5 {0} ) | grep {1}) || ( echo {2} && exit 1 )"),
267264
QuoteString(dest),
268265
md5sum,
269266
QuoteString("MD5 did not match!"),
@@ -1694,7 +1691,7 @@ def flags(path: str, flags: list[str] | None = None, present=True):
16941691
yield StringCommand("chflags", new_flags, QuoteString(path))
16951692
else:
16961693
host.noop(
1697-
f'\'{path}\' already has \'{",".join(flags)}\' {"set" if present else "clear"}',
1694+
f"'{path}' already has '{','.join(flags)}' {'set' if present else 'clear'}",
16981695
)
16991696

17001697

src/pyinfra/operations/iptables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def rule(
186186
# --log-prefix is only supported with jump=LOG
187187
if log_prefix and jump != "LOG":
188188
raise OperationError(
189-
"iptables only supports log_prefix with the LOG jump " "(jump={0})".format(jump),
189+
"iptables only supports log_prefix with the LOG jump (jump={0})".format(jump),
190190
)
191191

192192
definition = {

0 commit comments

Comments
 (0)