From 457e790bd016fedbad3c3bc89188560837426ef9 Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:51:06 +0000 Subject: [PATCH] Enable most flake8-bugbear rules in ruff (#3110) --- archinstall/lib/installer.py | 2 +- archinstall/lib/models/mirrors.py | 2 +- archinstall/tui/curses_menu.py | 4 ++-- pyproject.toml | 7 +++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 43ef6ac4ed..692786a14a 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1159,7 +1159,7 @@ def _add_grub_bootloader( config = grub_default.read_text() kernel_parameters = ' '.join(self._get_kernel_params(root, False, False)) - config = re.sub(r'(GRUB_CMDLINE_LINUX=")("\n)', rf'\1{kernel_parameters}\2', config, 1) + config = re.sub(r'(GRUB_CMDLINE_LINUX=")("\n)', rf'\1{kernel_parameters}\2', config, count=1) grub_default.write_text(config) diff --git a/archinstall/lib/models/mirrors.py b/archinstall/lib/models/mirrors.py index 9d3adbc7f1..f899bc5e46 100644 --- a/archinstall/lib/models/mirrors.py +++ b/archinstall/lib/models/mirrors.py @@ -61,7 +61,7 @@ def speed(self) -> float: self._speed = size / timer.time debug(f" speed: {self._speed} ({int(self._speed / 1024 / 1024 * 100) / 100}MiB/s)") # Do not retry error - except (urllib.error.URLError, ) as error: + except urllib.error.URLError as error: debug(f" speed: ({error}), skip") self._speed = 0 # Do retry error diff --git a/archinstall/tui/curses_menu.py b/archinstall/tui/curses_menu.py index a8f0b9c13f..c28d322f59 100644 --- a/archinstall/tui/curses_menu.py +++ b/archinstall/tui/curses_menu.py @@ -114,8 +114,8 @@ def get_header_entries( full_header = [] if header: - for header in header.split('\n'): - full_header += [ViewportEntry(header, cur_row, offset, STYLE.NORMAL)] + for line in header.split('\n'): + full_header += [ViewportEntry(line, cur_row, offset, STYLE.NORMAL)] cur_row += 1 return full_header diff --git a/pyproject.toml b/pyproject.toml index 52ea5a542b..1f1aa03c35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -180,6 +180,7 @@ line-length = 160 [tool.ruff.lint] select = [ "ASYNC", # flake8-async + "B", # flake8-bugbear "C90", # mccabe "DTZ", # flake8-datetimez "E", # pycodestyle errors @@ -206,6 +207,12 @@ select = [ ] ignore = [ + "B005", # strip-with-multi-characters + "B006", # mutable-argument-default + "B008", # function-call-in-default-argument + "B010", # set-attr-with-constant + "B904", # raise-without-from-inside-except + "B905", # zip-without-explicit-strict "PLC0415", # import-outside-top-level "PLC1901", # compare-to-empty-string "PLW1514", # unspecified-encoding