diff --git a/pyanaconda/display.py b/pyanaconda/display.py index f9742621f0c..91291ffbbd1 100644 --- a/pyanaconda/display.py +++ b/pyanaconda/display.py @@ -243,7 +243,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 diff --git a/pyanaconda/modules/payloads/payload/dnf/tree_info.py b/pyanaconda/modules/payloads/payload/dnf/tree_info.py index edba8c8c506..e9e8dae734b 100644 --- a/pyanaconda/modules/payloads/payload/dnf/tree_info.py +++ b/pyanaconda/modules/payloads/payload/dnf/tree_info.py @@ -311,7 +311,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) diff --git a/pyanaconda/modules/security/installation.py b/pyanaconda/modules/security/installation.py index e947733735d..8a418e60a97 100644 --- a/pyanaconda/modules/security/installation.py +++ b/pyanaconda/modules/security/installation.py @@ -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: diff --git a/pyanaconda/ui/tui/spokes/network.py b/pyanaconda/ui/tui/spokes/network.py index 93e3deb9a28..26e4549e454 100644 --- a/pyanaconda/ui/tui/spokes/network.py +++ b/pyanaconda/ui/tui/spokes/network.py @@ -116,9 +116,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) diff --git a/tests/ruff/ruff.toml b/tests/ruff/ruff.toml index 567047b0a15..17072510715 100644 --- a/tests/ruff/ruff.toml +++ b/tests/ruff/ruff.toml @@ -10,6 +10,7 @@ select = [ "F", # pyflakes "I", # isort "W", # pycodestyle warning (mostly whitespace related) + "PIE", # flake8-pie "PL", # pylint "ICN", # flake8-import-conventions "G", # flake8-logging-format @@ -25,6 +26,7 @@ ignore = [ "F405", # `` may be undefined, or defined from star imports: `` "F403", # `from 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 `` is discouraged "PLR2004", # Magic value used in comparison, consider replacing with a constant variable "PLR0913", # Too many arguments to function call (N > 5) diff --git a/tests/unit_tests/pyanaconda_tests/modules/common/test_tasks.py b/tests/unit_tests/pyanaconda_tests/modules/common/test_tasks.py index 85a5af4fabe..953e9257fa4 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/common/test_tasks.py +++ b/tests/unit_tests/pyanaconda_tests/modules/common/test_tasks.py @@ -314,7 +314,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 diff --git a/tests/unit_tests/pyanaconda_tests/modules/storage/partitioning/test_module_part_blivet.py b/tests/unit_tests/pyanaconda_tests/modules/storage/partitioning/test_module_part_blivet.py index 0c4a376282a..09fcf5dfbd6 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/storage/partitioning/test_module_part_blivet.py +++ b/tests/unit_tests/pyanaconda_tests/modules/storage/partitioning/test_module_part_blivet.py @@ -57,7 +57,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.