Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix-3081
Browse files Browse the repository at this point in the history
  • Loading branch information
svartkanin committed Jan 12, 2025
2 parents 5e78277 + 457e790 commit db306aa
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [#[email protected]](irc://#archinstall@irc.libera.chat:6697)
* archinstall [#[email protected]:6697](https://web.libera.chat/?channel=#archinstall)
* archinstall [documentation](https://archinstall.archlinux.page/)

# Installation & Usage
Expand Down
8 changes: 4 additions & 4 deletions archinstall/lib/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 2 additions & 6 deletions archinstall/lib/disk/disk_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand All @@ -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'

Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/disk/encryption_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/disk/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 5 additions & 5 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/interactions/disk_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/models/mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: <undetermined> ({error}), skip")
self._speed = 0
# Do retry error
Expand Down Expand Up @@ -261,7 +261,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',
Expand Down
15 changes: 7 additions & 8 deletions archinstall/lib/profile/profiles_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion archinstall/scripts/minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions archinstall/tui/curses_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit db306aa

Please sign in to comment.