use f-strings (#10899)

* use f-strings

* add changelog frag

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2025-10-11 22:59:28 +13:00 committed by GitHub
commit 3734f471c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 50 additions and 54 deletions

View file

@ -649,7 +649,7 @@ class Connection(ConnectionBase):
if password_prompt:
if self.become:
become_pass = self.become.get_option('become_pass')
chan.sendall(to_bytes(become_pass + '\n', errors='surrogate_or_strict'))
chan.sendall(to_bytes(f"{become_pass}\n", errors='surrogate_or_strict'))
else:
raise AnsibleError('A password is required but none was supplied')
else:
@ -687,9 +687,7 @@ class Connection(ConnectionBase):
with open(in_path, 'rb') as f:
data = f.read()
returncode, stdout, stderr = self.exec_command(
' '.join([
self._shell.executable, '-c',
self._shell.quote(f'cat > {out_path}')]),
f"{self._shell.executable} -c {self._shell.quote(f'cat > {out_path}')}",
in_data=data,
sudoable=False)
if returncode != 0:
@ -708,9 +706,7 @@ class Connection(ConnectionBase):
display.vvv(f'FETCH {in_path} TO {out_path}', host=self.get_option('remote_addr'))
try:
returncode, stdout, stderr = self.exec_command(
' '.join([
self._shell.executable, '-c',
self._shell.quote(f'cat {in_path}')]),
f"{self._shell.executable} -c {self._shell.quote(f'cat {in_path}')}",
sudoable=False)
if returncode != 0:
if 'cat: not found' in stderr.decode('utf-8'):