Skip to content

Commit

Permalink
tests: ruff: fix newly created RUF010 errors
Browse files Browse the repository at this point in the history
These were uncovered with the f-string porting:
Let's autfix these as well with: ruff check --fix --select RUF010 .
  • Loading branch information
KKoukiou committed Jun 27, 2024
1 parent 49f225d commit 8417ef2
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyanaconda/modules/payloads/payload/dnf/dnf_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def _run_transaction(base, display):
if transaction_has_errors(base.transaction):
display.error("The transaction process has ended with errors.")
except BaseException as e: # pylint: disable=broad-except
display.error(f"The transaction process has ended abruptly: {str(e)}\n{traceback.format_exc()}")
display.error(f"The transaction process has ended abruptly: {e!s}\n{traceback.format_exc()}")
finally:
log.debug("The transaction has ended.")
base.close() # Always close this base.
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/modules/payloads/payload/dnf/tree_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _load_tree_info(self, root_url, file_path=None, file_content=None):

except configparser.Error as e:
log.debug("Failed to load treeinfo metadata: %s", e)
raise InvalidTreeInfoError(f"Invalid metadata: {str(e)}") from None
raise InvalidTreeInfoError(f"Invalid metadata: {e!s}") from None

# Update this treeinfo representation.
self._repositories = repo_list
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/modules/payloads/source/nfs/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _set_up_source(self):
try:
self._mount_nfs(host, options, path, self._device_mount)
except OSError as e:
msg = f"Failed to mount the NFS source at '{self._url}': {str(e)}"
msg = f"Failed to mount the NFS source at '{self._url}': {e!s}"
raise SourceSetupError(msg) from None

# Mount an ISO if any.
Expand Down
4 changes: 2 additions & 2 deletions pyanaconda/modules/storage/devicetree/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def mount_device(self, device_name, mount_point, options):
try:
device.format.mount(mountpoint=mount_point, options=options or None)
except FSError as e:
msg = f"Failed to mount {device_name} at {mount_point}: {str(e)}"
msg = f"Failed to mount {device_name} at {mount_point}: {e!s}"
raise MountFilesystemError(msg) from None

def unmount_device(self, device_name, mount_point):
Expand All @@ -81,7 +81,7 @@ def unmount_device(self, device_name, mount_point):
try:
device.format.unmount(mountpoint=mount_point)
except FSError as e:
msg = f"Failed to unmount {device_name} from {mount_point}: {str(e)}"
msg = f"Failed to unmount {device_name} from {mount_point}: {e!s}"
raise MountFilesystemError(msg) from None

def unlock_device(self, device_name, passphrase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def get_device_factory_arguments(storage, request: DeviceFactoryRequest, subset=

log.debug(
"Generated factory arguments: {\n%s\n}",
",\n".join(f"{name} = {repr(value)}" for name, value in args.items())
",\n".join(f"{name} = {value!r}" for name, value in args.items())
)

return args
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/modules/subscription/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def process_kickstart(self, data):
subscription_request.server_proxy_password.set_secret(proxy.password)
except ProxyStringError as e:
# should not be fatal, but definitely logged as error
message = f"Failed to parse proxy for the rhsm command: {str(e)}"
message = f"Failed to parse proxy for the rhsm command: {e!s}"
warnings.warn(message, KickstartParseWarning)

# set the resulting subscription request
Expand Down
4 changes: 2 additions & 2 deletions pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ def generate_request_description(request, original=None):
old_value = field.get_data(original)

if new_value == old_value:
attribute = f"{name} = {repr(new_value)}"
attribute = f"{name} = {new_value!r}"
else:
attribute = f"{name} = {repr(old_value)} -> {repr(new_value)}"
attribute = f"{name} = {old_value!r} -> {new_value!r}"

attributes.append(attribute)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def generate_repository_description(repo_data):

for name, field in fields.items():
value = field.get_data(repo_data)
attribute = f"{name} = {repr(value)}"
attribute = f"{name} = {value!r}"
attributes.append(attribute)

return "\n".join(["{"] + attributes + ["}"])
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/ui/tui/spokes/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def _default_connection_added_cb(self, client, result, data):
try:
_connection, result = client.add_connection2_finish(result)
except Exception as e: # pylint: disable=broad-except
msg = f"adding default connection {connection_uuid} from {iface} failed: {str(e)}"
msg = f"adding default connection {connection_uuid} from {iface} failed: {e!s}"
log.error(msg)
self.errors.append(msg)
self.redraw()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/pyanaconda_tests/test_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _generate_id(self):

def _create_source(self, source_type, source_url):
"""Create a source from the specified URL and check its type."""
source_path = f"/my/source/{str(self._generate_id())}"
source_path = f"/my/source/{self._generate_id()!s}"

payloads_proxy = PAYLOADS.get_proxy()
payloads_proxy.CreateSource.return_value = source_path
Expand Down

0 comments on commit 8417ef2

Please sign in to comment.