diff --git a/pyanaconda/display.py b/pyanaconda/display.py index 196ec2d857e..75fd683a196 100644 --- a/pyanaconda/display.py +++ b/pyanaconda/display.py @@ -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 diff --git a/pyanaconda/modules/payloads/payload/dnf/tree_info.py b/pyanaconda/modules/payloads/payload/dnf/tree_info.py index f9cfab2cd0b..d9a88a56582 100644 --- a/pyanaconda/modules/payloads/payload/dnf/tree_info.py +++ b/pyanaconda/modules/payloads/payload/dnf/tree_info.py @@ -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) diff --git a/pyanaconda/modules/security/installation.py b/pyanaconda/modules/security/installation.py index 82eae14896c..cf8e2630b63 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 4c44ecbed3f..8b35b2fe32a 100644 --- a/pyanaconda/ui/tui/spokes/network.py +++ b/pyanaconda/ui/tui/spokes/network.py @@ -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) diff --git a/tests/ruff/ruff.toml b/tests/ruff/ruff.toml index 83f4192a02a..1f821299332 100644 --- a/tests/ruff/ruff.toml +++ b/tests/ruff/ruff.toml @@ -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 @@ -24,6 +25,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 e74fb17f0a8..46e51b00086 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/common/test_tasks.py +++ b/tests/unit_tests/pyanaconda_tests/modules/common/test_tasks.py @@ -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 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 a37d130b554..0366480685c 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 @@ -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.