From 7202d964ddda2a51ddec809f1671cd2993b9dca6 Mon Sep 17 00:00:00 2001 From: Melroy van den Berg Date: Sun, 12 Jan 2025 01:27:30 +0100 Subject: [PATCH 1/7] Make libera.chat irc link clickable (#3099) Fix libera.chat link in markdown --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c32892cdb..05da0c8796 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The installer also doubles as a python library to install Arch Linux and manage * archinstall [discord](https://discord.gg/aDeMffrxNg) server * archinstall [#archinstall:matrix.org](https://matrix.to/#/#archinstall:matrix.org) Matrix channel -* archinstall [#archinstall@irc.libera.chat](irc://#archinstall@irc.libera.chat:6697) +* archinstall [#archinstall@irc.libera.chat:6697](https://web.libera.chat/?channel=#archinstall) * archinstall [documentation](https://archinstall.archlinux.page/) # Installation & Usage From 3409f84e79bfa497b2ff74cc021be91c15e55cf6 Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:30:27 -0500 Subject: [PATCH 2/7] Use list comprehension (#3105) --- archinstall/lib/disk/disk_menu.py | 8 ++------ archinstall/lib/disk/encryption_menu.py | 4 ++-- archinstall/lib/disk/filesystem.py | 2 +- archinstall/lib/installer.py | 2 +- archinstall/lib/interactions/disk_conf.py | 2 +- archinstall/lib/profile/profiles_handler.py | 15 +++++++-------- archinstall/scripts/minimal.py | 2 +- examples/minimal_installation.py | 2 +- 8 files changed, 16 insertions(+), 21 deletions(-) diff --git a/archinstall/lib/disk/disk_menu.py b/archinstall/lib/disk/disk_menu.py index 1e255aa610..9e91e3ce0b 100644 --- a/archinstall/lib/disk/disk_menu.py +++ b/archinstall/lib/disk/disk_menu.py @@ -2,7 +2,6 @@ from archinstall.tui import MenuItem, MenuItemGroup -from ..disk import DeviceModification from ..interactions import select_disk_config from ..interactions.disk_conf import select_lvm_config from ..menu import AbstractSubMenu @@ -101,8 +100,7 @@ def _prev_disk_layouts(self, item: MenuItem) -> str | None: msg += str(_('Mountpoint')) + ': ' + str(disk_layout_conf.mountpoint) return msg - device_mods: list[DeviceModification] = \ - list(filter(lambda x: len(x.partitions) > 0, disk_layout_conf.device_modifications)) + device_mods = [d for d in disk_layout_conf.device_modifications if d.partitions] if device_mods: output_partition = '{}: {}\n'.format(str(_('Configuration')), disk_layout_conf.config_type.display_msg()) @@ -116,9 +114,7 @@ def _prev_disk_layouts(self, item: MenuItem) -> str | None: output_partition += partition_table + '\n' # create btrfs table - btrfs_partitions = list( - filter(lambda p: len(p.btrfs_subvols) > 0, mod.partitions) - ) + btrfs_partitions = [p for p in mod.partitions if p.btrfs_subvols] for partition in btrfs_partitions: output_btrfs += FormattedOutput.as_table(partition.btrfs_subvols) + '\n' diff --git a/archinstall/lib/disk/encryption_menu.py b/archinstall/lib/disk/encryption_menu.py index 3f8e99f3c9..1d62935ef8 100644 --- a/archinstall/lib/disk/encryption_menu.py +++ b/archinstall/lib/disk/encryption_menu.py @@ -284,10 +284,10 @@ def select_partitions_to_encrypt( # do not allow encrypting the boot partition for mod in modification: - partitions += list(filter(lambda x: x.mountpoint != Path('/boot'), mod.partitions)) + partitions += [p for p in mod.partitions if p.mountpoint != Path('/boot')] # do not allow encrypting existing partitions that are not marked as wipe - avail_partitions = list(filter(lambda x: not x.exists(), partitions)) + avail_partitions = [p for p in partitions if not p.exists()] if avail_partitions: group, header = MenuHelper.create_table(data=avail_partitions) diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py index 9f906e589c..874c41ae53 100644 --- a/archinstall/lib/disk/filesystem.py +++ b/archinstall/lib/disk/filesystem.py @@ -49,7 +49,7 @@ def perform_filesystem_operations(self, show_countdown: bool = True) -> None: debug('Disk layout configuration is set to pre-mount, not performing any operations') return - device_mods = list(filter(lambda x: len(x.partitions) > 0, self._disk_config.device_modifications)) + device_mods = [d for d in self._disk_config.device_modifications if d.partitions] if not device_mods: debug('No modifications required') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index f8ea21141c..064a1a355d 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -242,7 +242,7 @@ def _mount_partition_layout(self, luks_handlers: dict[Any, Luks2]) -> None: break for mod in sorted_device_mods: - not_pv_part_mods = list(filter(lambda x: x not in pvs, mod.partitions)) + not_pv_part_mods = [p for p in mod.partitions if p not in pvs] # partitions have to mounted in the right order on btrfs the mountpoint will # be empty as the actual subvolumes are getting mounted instead so we'll use diff --git a/archinstall/lib/interactions/disk_conf.py b/archinstall/lib/interactions/disk_conf.py index d48b419a3b..1847f30de8 100644 --- a/archinstall/lib/interactions/disk_conf.py +++ b/archinstall/lib/interactions/disk_conf.py @@ -462,7 +462,7 @@ def suggest_multi_disk_layout( filesystem_type = select_main_filesystem_format(advanced_options) # find proper disk for /home - possible_devices = list(filter(lambda x: x.device_info.total_size >= min_home_partition_size, devices)) + possible_devices = [d for d in devices if d.device_info.total_size >= min_home_partition_size] home_device = max(possible_devices, key=lambda d: d.device_info.total_size) if possible_devices else None # find proper device for /root diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py index 2b0bc3c2fe..f5bbde17aa 100644 --- a/archinstall/lib/profile/profiles_handler.py +++ b/archinstall/lib/profile/profiles_handler.py @@ -164,21 +164,20 @@ def get_profile_by_name(self, name: str) -> Profile | None: return next(filter(lambda x: x.name == name, self.profiles), None) # type: ignore def get_top_level_profiles(self) -> list[Profile]: - return list(filter(lambda x: x.is_top_level_profile(), self.profiles)) + return [p for p in self.profiles if p.is_top_level_profile()] def get_server_profiles(self) -> list[Profile]: - return list(filter(lambda x: x.is_server_type_profile(), self.profiles)) + return [p for p in self.profiles if p.is_server_type_profile()] def get_desktop_profiles(self) -> list[Profile]: - return list(filter(lambda x: x.is_desktop_type_profile(), self.profiles)) + return [p for p in self.profiles if p.is_desktop_type_profile()] def get_custom_profiles(self) -> list[Profile]: - return list(filter(lambda x: x.is_custom_type_profile(), self.profiles)) + return [p for p in self.profiles if p.is_custom_type_profile()] def get_mac_addr_profiles(self) -> list[Profile]: - tailored = list(filter(lambda x: x.is_tailored(), self.profiles)) - match_mac_addr_profiles = list(filter(lambda x: x.name in self._local_mac_addresses, tailored)) - return match_mac_addr_profiles + tailored = [p for p in self.profiles if p.is_tailored()] + return [t for t in tailored if t.name in self._local_mac_addresses] def install_greeter(self, install_session: 'Installer', greeter: GreeterType) -> None: packages = [] @@ -296,7 +295,7 @@ def _verify_unique_profile_names(self, profiles: list[Profile]) -> None: that the provided list contains only default_profiles with unique names """ counter = Counter([p.name for p in profiles]) - duplicates = list(filter(lambda x: x[1] != 1, counter.items())) + duplicates = [x for x in counter.items() if x[1] != 1] if len(duplicates) > 0: err = str(_('Profiles must have unique name, but profile definitions with duplicate name found: {}')).format(duplicates[0][0]) diff --git a/archinstall/scripts/minimal.py b/archinstall/scripts/minimal.py index 3395b7b0c7..e287f78045 100644 --- a/archinstall/scripts/minimal.py +++ b/archinstall/scripts/minimal.py @@ -74,7 +74,7 @@ def parse_disk_encryption() -> None: # encrypt all partitions except the /boot for mod in modification: - partitions += list(filter(lambda x: x.mountpoint != Path('/boot'), mod.partitions)) + partitions += [p for p in mod.partitions if p.mountpoint != Path('/boot')] archinstall.arguments['disk_encryption'] = disk.DiskEncryption( encryption_type=disk.EncryptionType.Luks, diff --git a/examples/minimal_installation.py b/examples/minimal_installation.py index eeec2dc37e..f532206e8c 100644 --- a/examples/minimal_installation.py +++ b/examples/minimal_installation.py @@ -74,7 +74,7 @@ def parse_disk_encryption() -> None: # encrypt all partitions except the /boot for mod in modification: - partitions += list(filter(lambda x: x.mountpoint != Path('/boot'), mod.partitions)) + partitions += [p for p in mod.partitions if p.mountpoint != Path('/boot')] archinstall.arguments['disk_encryption'] = disk.DiskEncryption( encryption_type=disk.EncryptionType.Luks, From df2791295d0db6b576e9456f51423bc1a8dd7f5e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 11:30:59 +1100 Subject: [PATCH 3/7] chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.9.1 (#3100) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9268102f34..7c10dec925 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,7 +47,7 @@ repos: - pydantic-settings - pytest - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.9.0 + rev: v0.9.1 hooks: - id: ruff - repo: local From 47736c406059b7abba5d62897e43b648930b7f99 Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:45:41 +0000 Subject: [PATCH 4/7] Avoid reassigning a parameter value to fix Pyright warnings (#3106) --- archinstall/lib/configuration.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/archinstall/lib/configuration.py b/archinstall/lib/configuration.py index 1552f1f58a..e1aab325bd 100644 --- a/archinstall/lib/configuration.py +++ b/archinstall/lib/configuration.py @@ -126,11 +126,11 @@ def save_user_creds(self, dest_path: Path) -> None: target.chmod(stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) def save(self, dest_path: Path | None = None) -> None: - dest_path = dest_path or self._default_save_path + save_path = dest_path or self._default_save_path - if self._is_valid_path(dest_path): - self.save_user_config(dest_path) - self.save_user_creds(dest_path) + if self._is_valid_path(save_path): + self.save_user_config(save_path) + self.save_user_creds(save_path) def save_config(config: dict[str, Any]) -> None: From 668150190404b169b2e5895278f3ee97a939b371 Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:46:34 -0500 Subject: [PATCH 5/7] Fix Btrfs subvolume mount options (#3108) --- archinstall/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 064a1a355d..6e669b8c2a 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -363,8 +363,8 @@ def _mount_btrfs_subvol( ) -> None: for subvol in sorted(subvolumes, key=lambda x: x.relative_mountpoint): mountpoint = self.target / subvol.relative_mountpoint - mount_options = mount_options + [f'subvol={subvol.name}'] - disk.device_handler.mount(dev_path, mountpoint, options=mount_options) + options = mount_options + [f'subvol={subvol.name}'] + disk.device_handler.mount(dev_path, mountpoint, options=options) def generate_key_files(self) -> None: match self._disk_encryption.encryption_type: From 4212357c6fa22ae1b7c587b8993d91885d66bd45 Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sun, 12 Jan 2025 00:50:09 +0000 Subject: [PATCH 6/7] Use removeprefix/removesuffix instead of incorrect lstrip/rstrip calls (#3109) --- archinstall/lib/installer.py | 2 +- archinstall/lib/models/mirrors.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 6e669b8c2a..43ef6ac4ed 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1633,7 +1633,7 @@ def _service_started(self, service_name: str) -> str | None: last_execution_time = SysCommand( f"systemctl show --property=ActiveEnterTimestamp --no-pager {service_name}", environment_vars={'SYSTEMD_COLORS': '0'} - ).decode().lstrip('ActiveEnterTimestamp=') + ).decode().removeprefix('ActiveEnterTimestamp=') if not last_execution_time: return None diff --git a/archinstall/lib/models/mirrors.py b/archinstall/lib/models/mirrors.py index 09aec8f392..9d3adbc7f1 100644 --- a/archinstall/lib/models/mirrors.py +++ b/archinstall/lib/models/mirrors.py @@ -254,7 +254,7 @@ def _parse_locale_mirrors(self, mirrorlist: str) -> dict[str, list[MirrorStatusE url = line.removeprefix('Server = ') mirror_entry = MirrorStatusEntryV3( - url=url.rstrip('$repo/os/$arch'), + url=url.removesuffix('$repo/os/$arch'), protocol=urllib.parse.urlparse(url).scheme, active=True, country=current_region or 'Worldwide', 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 7/7] 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