Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion archinstall/default_profiles/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class DesktopProfile(Profile):
def __init__(self, current_selection: list[Self] = []) -> None:
def __init__(self, current_selection: list[Self] | None = None) -> None:
super().__init__(
'Desktop',
ProfileType.Desktop,
Expand Down
13 changes: 8 additions & 5 deletions archinstall/default_profiles/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def __init__(
self,
name: str,
profile_type: ProfileType,
current_selection: list[Self] = [],
packages: list[str] = [],
services: list[str] = [],
current_selection: list[Self] | None = None,
packages: list[str] | None = None,
services: list[str] | None = None,
support_gfx_driver: bool = False,
support_greeter: bool = False,
display_server: DisplayServerType | None = None,
Expand All @@ -73,9 +73,12 @@ def __init__(

# self.gfx_driver: str | None = None

if current_selection is None:
current_selection = []

self.current_selection = current_selection
self._packages = packages
self._services = services
self._packages = packages if packages is not None else []
self._services = services if services is not None else []

# Only used for custom default_profiles
self.custom_enabled = False
Expand Down
2 changes: 1 addition & 1 deletion archinstall/default_profiles/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class ServerProfile(Profile):
def __init__(self, current_value: list[Self] = []):
def __init__(self, current_value: list[Self] | None = None):
super().__init__(
'Server',
ProfileType.Server,
Expand Down
5 changes: 4 additions & 1 deletion archinstall/lib/disk/device_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def format(
self,
fs_type: FilesystemType,
path: Path,
additional_parted_options: list[str] = [],
additional_parted_options: list[str] | None = None,
) -> None:
mkfs_type = fs_type.value
command = None
Expand Down Expand Up @@ -264,6 +264,9 @@ def format(
if not command:
command = f'mkfs.{mkfs_type}'

if additional_parted_options is None:
additional_parted_options = []

cmd = [command, *options, *additional_parted_options, str(path)]

debug('Formatting filesystem:', ' '.join(cmd))
Expand Down
10 changes: 5 additions & 5 deletions archinstall/lib/disk/disk_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def _prev_disk_encryption(self, item: MenuItem) -> str | None:
return None


async def select_devices(preset: list[BDevice] | None = []) -> list[BDevice] | None:
async def select_devices(preset: list[BDevice] | None = None) -> list[BDevice] | None:
def _preview_device_selection(item: MenuItem) -> str | None:
device: _DeviceInfo = item.value # type: ignore[assignment]
dev = device_handler.get_device(device.path)
Expand All @@ -306,9 +306,6 @@ def _preview_device_selection(item: MenuItem) -> str | None:
return as_table(dev.partition_infos)
return None

if preset is None:
preset = []

devices = device_handler.devices

if len(devices) < 1:
Expand All @@ -324,7 +321,10 @@ def _preview_device_selection(item: MenuItem) -> str | None:
for d in devices
]

presets = [p.device_info for p in preset]
if preset is None:
presets = []
else:
presets = [p.device_info for p in preset]

group = MenuItemGroup(items)
group.set_selected_by_value(presets)
Expand Down
12 changes: 6 additions & 6 deletions archinstall/lib/disk/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _setup_lvm_encrypted(self, lvm_config: LvmConfiguration, enc_config: DiskEnc
def _setup_lvm(
self,
lvm_config: LvmConfiguration,
enc_mods: dict[PartitionModification, Luks2] = {},
enc_mods: dict[PartitionModification, Luks2] | None = None,
) -> None:
self._lvm_create_pvs(lvm_config, enc_mods)

Expand Down Expand Up @@ -216,10 +216,10 @@ def _setup_lvm(
def _format_lvm_vols(
self,
lvm_config: LvmConfiguration,
enc_vols: dict[LvmVolume, Luks2] = {},
enc_vols: dict[LvmVolume, Luks2] | None = None,
) -> None:
for vol in lvm_config.get_all_volumes():
if enc_vol := enc_vols.get(vol, None):
if enc_vols is not None and (enc_vol := enc_vols.get(vol, None)):
if not enc_vol.mapper_dev:
raise ValueError('No mapper device defined')
path = enc_vol.mapper_dev
Expand All @@ -236,7 +236,7 @@ def _format_lvm_vols(
def _lvm_create_pvs(
self,
lvm_config: LvmConfiguration,
enc_mods: dict[PartitionModification, Luks2] = {},
enc_mods: dict[PartitionModification, Luks2] | None = None,
) -> None:
pv_paths: set[Path] = set()

Expand All @@ -248,12 +248,12 @@ def _lvm_create_pvs(
def _get_all_pv_dev_paths(
self,
pvs: list[PartitionModification],
enc_mods: dict[PartitionModification, Luks2] = {},
enc_mods: dict[PartitionModification, Luks2] | None = None,
) -> set[Path]:
pv_paths: set[Path] = set()

for pv in pvs:
if enc_pv := enc_mods.get(pv, None):
if enc_mods is not None and (enc_pv := enc_mods.get(pv, None)):
if mapper := enc_pv.mapper_dev:
pv_paths.add(mapper)
else:
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/disk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def mount(
target_mountpoint: Path,
mount_fs: str | None = None,
create_target_mountpoint: bool = True,
options: list[str] = [],
options: list[str] | None = None,
) -> None:
if create_target_mountpoint and not target_mountpoint.exists():
target_mountpoint.mkdir(parents=True, exist_ok=True)
Expand All @@ -156,7 +156,7 @@ def mount(

cmd = ['mount']

if len(options):
if options:
cmd.extend(('-o', ','.join(options)))
if mount_fs:
cmd.extend(('-t', mount_fs))
Expand Down
10 changes: 8 additions & 2 deletions archinstall/lib/general/system_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
from archinstall.tui.result import ResultType


async def select_kernel(preset: list[Kernel] = []) -> list[Kernel]:
async def select_kernel(preset: list[Kernel] | None = None) -> list[Kernel]:
"""
Asks the user to select a kernel for system.

:return: The string as a selected kernel
:rtype: string
"""
if preset is None:
preset = []

group = MenuItemGroup.from_enum(Kernel, sort_items=True, preset=preset)
group.set_default_by_value(DEFAULT_KERNEL)
group.set_focus_by_value(DEFAULT_KERNEL)
Expand Down Expand Up @@ -51,7 +54,10 @@ async def select_uki(preset: bool = True) -> bool:
raise ValueError('Unhandled result type')


async def select_driver(options: list[GfxDriver] = [], preset: GfxDriver | None = None) -> GfxDriver | None:
async def select_driver(
options: list[GfxDriver] | None = None,
preset: GfxDriver | None = None,
) -> GfxDriver | None:
"""
Somewhat convoluted function, whose job is simple.
Select a graphics driver from a pre-defined set of popular options.
Expand Down
16 changes: 11 additions & 5 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(
self,
target: Path,
disk_config: DiskLayoutConfiguration,
base_packages: list[str] = [],
base_packages: list[str] | None = None,
kernels: list[str] | None = None,
silent: bool = False,
):
Expand Down Expand Up @@ -312,7 +312,7 @@ def _mount_partition_layout(self, luks_handlers: dict[Any, Luks2]) -> None:
else:
self._mount_partition(part_mod)

def _mount_lvm_layout(self, luks_handlers: dict[Any, Luks2] = {}) -> None:
def _mount_lvm_layout(self, luks_handlers: dict[Any, Luks2] | None = None) -> None:
lvm_config = self._disk_config.lvm_config

if not lvm_config:
Expand All @@ -325,7 +325,7 @@ def _mount_lvm_layout(self, luks_handlers: dict[Any, Luks2] = {}) -> None:
sorted_vol = sorted(vg.volumes, key=lambda x: x.mountpoint or Path('/'))

for vol in sorted_vol:
if luks_handler := luks_handlers.get(vol):
if luks_handlers is not None and (luks_handler := luks_handlers.get(vol)):
self._mount_luks_volume(vol, luks_handler)
else:
self._mount_lvm_vol(vol)
Expand Down Expand Up @@ -437,8 +437,11 @@ def _mount_btrfs_subvol(
self,
dev_path: Path,
subvolumes: list[SubvolumeModification],
mount_options: list[str] = [],
mount_options: list[str] | None = None,
) -> None:
if mount_options is None:
mount_options = []

# Filter out subvolumes without mountpoints to avoid errors when sorting
subvols_with_mountpoints = [sv for sv in subvolumes if sv.mountpoint is not None]
for subvol in sorted(subvols_with_mountpoints, key=lambda x: x.relative_mountpoint):
Expand Down Expand Up @@ -897,7 +900,7 @@ def _prepare_encrypt(self, before: str = 'filesystems') -> None:

def minimal_installation(
self,
optional_repositories: list[Repository] = [],
optional_repositories: list[Repository] | None = None,
mkinitcpio: bool = True,
hostname: str | None = None,
locale_config: LocaleConfiguration | None = LocaleConfiguration.default(),
Expand Down Expand Up @@ -933,6 +936,9 @@ def minimal_installation(
else:
debug('Archinstall will not install any ucode.')

if optional_repositories is None:
optional_repositories = []

debug(f'Optional repositories: {optional_repositories}')

# This action takes place on the host system as pacstrap copies over package repository lists.
Expand Down
17 changes: 9 additions & 8 deletions archinstall/lib/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _stylize_output(
fg: str,
bg: str | None,
reset: bool,
font: list[Font] = [],
font: list[Font] | None = None,
) -> str:
"""
Heavily influenced by:
Expand Down Expand Up @@ -137,8 +137,9 @@ def _stylize_output(
if bg:
code_list.append(background[str(bg)])

for o in font:
code_list.append(o.value)
if font is not None:
for o in font:
code_list.append(o.value)

ansi = ';'.join(code_list)

Expand Down Expand Up @@ -167,7 +168,7 @@ def info(
fg: str = 'white',
bg: str | None = None,
reset: bool = False,
font: list[Font] = [],
font: list[Font] | None = None,
) -> None:
log(*msgs, level=level, fg=fg, bg=bg, reset=reset, font=font)

Expand All @@ -178,7 +179,7 @@ def debug(
fg: str = 'white',
bg: str | None = None,
reset: bool = False,
font: list[Font] = [],
font: list[Font] | None = None,
) -> None:
log(*msgs, level=level, fg=fg, bg=bg, reset=reset, font=font)

Expand All @@ -189,7 +190,7 @@ def error(
fg: str = 'red',
bg: str | None = None,
reset: bool = False,
font: list[Font] = [],
font: list[Font] | None = None,
) -> None:
log(*msgs, level=level, fg=fg, bg=bg, reset=reset, font=font)

Expand All @@ -200,7 +201,7 @@ def warn(
fg: str = 'yellow',
bg: str | None = None,
reset: bool = False,
font: list[Font] = [],
font: list[Font] | None = None,
) -> None:
log(*msgs, level=level, fg=fg, bg=bg, reset=reset, font=font)

Expand All @@ -211,7 +212,7 @@ def log(
fg: str = 'white',
bg: str | None = None,
reset: bool = False,
font: list[Font] = [],
font: list[Font] | None = None,
) -> None:
text = ' '.join(str(x) for x in msgs)

Expand Down
5 changes: 4 additions & 1 deletion archinstall/lib/menu/menu_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ class MenuHelper[ValueT]:
def __init__(
self,
data: list[ValueT],
additional_options: list[str] = [],
additional_options: list[str] | None = None,
) -> None:
if additional_options is None:
additional_options = []

self._separator = ''
self._data = data
self._additional_options = additional_options
Expand Down
10 changes: 8 additions & 2 deletions archinstall/lib/mirror/mirror_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ async def select_mirror_regions(
return selected_mirrors


async def add_custom_mirror_servers(preset: list[CustomServer] = []) -> list[CustomServer]:
async def add_custom_mirror_servers(preset: list[CustomServer] | None = None) -> list[CustomServer]:
if preset is None:
preset = []

custom_mirrors = await CustomMirrorServersList(preset).show()

if not custom_mirrors:
Expand All @@ -346,7 +349,10 @@ async def add_custom_mirror_servers(preset: list[CustomServer] = []) -> list[Cus
return custom_mirrors


async def select_custom_mirror(preset: list[CustomRepository] = []) -> list[CustomRepository]:
async def select_custom_mirror(preset: list[CustomRepository] | None = None) -> list[CustomRepository]:
if preset is None:
preset = []

custom_mirrors = await CustomMirrorRepositoriesList(preset).show()

if not custom_mirrors:
Expand Down
5 changes: 4 additions & 1 deletion archinstall/lib/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def from_partition(
partition: Partition,
lsblk_info: LsblkInfo,
fs_type: FilesystemType | None,
btrfs_subvol_infos: list[_BtrfsSubvolumeInfo] = [],
btrfs_subvol_infos: list[_BtrfsSubvolumeInfo] | None = None,
) -> Self:
partition_type = PartitionType.get_type_from_code(partition.type)
flags = [f for f in PartitionFlag if partition.getFlag(f.flag_id)]
Expand All @@ -579,6 +579,9 @@ def from_partition(
SectorSize(partition.disk.device.sectorSize, Unit.B),
)

if btrfs_subvol_infos is None:
btrfs_subvol_infos = []

return cls(
partition=partition,
name=partition.get_name(),
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/models/mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def repositories_config(self) -> str:
def parse_args(
cls,
args: dict[str, Any],
backwards_compatible_repo: list[Repository] = [],
backwards_compatible_repo: list[Repository] | None = None,
) -> Self:
config = cls()

Expand Down
10 changes: 8 additions & 2 deletions archinstall/lib/packages/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,15 @@ def _parse_package_output[PackageType: (AvailablePackage, LocalPackage)](


async def select_additional_packages(
preset: list[str] = [],
repositories: set[Repository] = set(),
preset: list[str] | None = None,
repositories: set[Repository] | None = None,
) -> list[str]:
if preset is None:
preset = []

if repositories is None:
repositories = set()

repositories |= {Repository.Core, Repository.Extra}

respos_text = ', '.join(r.value for r in repositories)
Expand Down
Loading