Skip to content

Commit

Permalink
ruff: select flake8-pie Ruff rules and fix existing issues
Browse files Browse the repository at this point in the history
Auto fix:
* unnecessary-range-start (PIE808)
* multiple-starts-ends-with (PIE810)
  • Loading branch information
KKoukiou committed Dec 18, 2024
1 parent d5bc99b commit dcd12bf
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyanaconda/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def wl_preexec():
)
WatchProcesses.watch_process(childproc, argv[0])

for _i in range(0, int(timeout / 0.1)):
for _i in range(int(timeout / 0.1)):
wl_socket_path = os.path.join(os.getenv("XDG_RUNTIME_DIR"), constants.WAYLAND_SOCKET_NAME)
if os.path.exists(wl_socket_path):
return
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 @@ -306,7 +306,7 @@ def _download_metadata(self, downloader, url):
# full connectivity before trying to download things. (#1292613)
xdelay = xprogressive_delay()

for retry_count in range(0, retry_max):
for retry_count in range(retry_max):
# Delay if we are retrying the download.
if retry_count > 0:
log.info("Retrying download (%d/%d)", retry_count, retry_max - 1)
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/modules/security/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def run(self):
return

for arg in self._realm_data.join_options:
if arg.startswith("--no-password") or arg.startswith("--one-time-password"):
if arg.startswith(("--no-password", "--one-time-password")):
pw_args = []
break
else:
Expand Down
4 changes: 2 additions & 2 deletions pyanaconda/ui/tui/spokes/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def set_from_connection(self, connection):
self.ipv6gateway = ip6_config.get_gateway() or ""

nameservers = []
for i in range(0, ip4_config.get_num_dns()):
for i in range(ip4_config.get_num_dns()):
nameservers.append(ip4_config.get_dns(i))
for i in range(0, ip6_config.get_num_dns()):
for i in range(ip6_config.get_num_dns()):
nameservers.append(ip6_config.get_dns(i))
self.nameserver = ",".join(nameservers)

Expand Down
2 changes: 2 additions & 0 deletions tests/ruff/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ select = [
"E", # pycodestyle error
"F", # pyflakes
"W", # pycodestyle warning (mostly whitespace related)
"PIE", # flake8-pie
"PL", # pylint
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
Expand All @@ -24,6 +25,7 @@ ignore = [
"F405", # `<type>` may be undefined, or defined from star imports: `<module>`
"F403", # `from <module> import *` used; unable to detect undefined names
"E731", # Do not assign a `lambda` expression, use a `def`
"PIE790", # unnecessary-placeholder
"PLW0603", # Using the global statement to update `<variable>` is discouraged
"PLR2004", # Magic value used in comparison, consider replacing <value> with a constant variable
"PLR0913", # Too many arguments to function call (N > 5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def run(self):
timeout = TaskInterfaceTestCase.TIMEOUT

# Wait for the cancellation.
for _i in range(0, timeout * 10):
for _i in range(timeout * 10):
if self.check_cancel():
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_unsupported_partitioning(self):
"""Test the UnsupportedPartitioningError."""
# Forget imported modules from pyanaconda and blivetgui.
for name in list(sys.modules):
if name.startswith('pyanaconda') or name.startswith('blivetgui'):
if name.startswith(("pyanaconda", "blivetgui")):
sys.modules.pop(name)

# Disable the blivetgui package.
Expand Down

0 comments on commit dcd12bf

Please sign in to comment.