Skip to content

Commit

Permalink
Remove remaining deprecated typing.Dict and typing.List usage (archli…
Browse files Browse the repository at this point in the history
  • Loading branch information
correctmost authored Nov 18, 2024
1 parent 41e5a0f commit 9626965
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 75 deletions.
25 changes: 13 additions & 12 deletions archinstall/lib/disk/device_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import logging
import time
import uuid
from collections.abc import Iterable
from pathlib import Path
from typing import List, Dict, Any, Optional, TYPE_CHECKING, Literal, Iterable
from typing import Any, Optional, TYPE_CHECKING, Literal

from parted import (
Disk, Geometry, FileSystem,
Expand Down Expand Up @@ -37,11 +38,11 @@ class DeviceHandler:
_TMP_BTRFS_MOUNT = Path('/mnt/arch_btrfs')

def __init__(self) -> None:
self._devices: Dict[Path, BDevice] = {}
self._devices: dict[Path, BDevice] = {}
self.load_devices()

@property
def devices(self) -> List[BDevice]:
def devices(self) -> list[BDevice]:
return list(self._devices.values())

def load_devices(self) -> None:
Expand Down Expand Up @@ -195,11 +196,11 @@ def get_btrfs_info(
self,
dev_path: Path,
lsblk_info: Optional[LsblkInfo] = None
) -> List[_BtrfsSubvolumeInfo]:
) -> list[_BtrfsSubvolumeInfo]:
if not lsblk_info:
lsblk_info = get_lsblk_info(dev_path)

subvol_infos: List[_BtrfsSubvolumeInfo] = []
subvol_infos: list[_BtrfsSubvolumeInfo] = []

if not lsblk_info.mountpoint:
self.mount(dev_path, self._TMP_BTRFS_MOUNT, create_target_mountpoint=True)
Expand Down Expand Up @@ -247,7 +248,7 @@ def format(
self,
fs_type: FilesystemType,
path: Path,
additional_parted_options: List[str] = []
additional_parted_options: list[str] = []
) -> None:
mkfs_type = fs_type.value
options = []
Expand Down Expand Up @@ -561,8 +562,8 @@ def fetch_part_info(self, path: Path) -> LsblkInfo:
def create_lvm_btrfs_subvolumes(
self,
path: Path,
btrfs_subvols: List[SubvolumeModification],
mount_options: List[str]
btrfs_subvols: list[SubvolumeModification],
mount_options: list[str]
) -> None:
info(f'Creating subvolumes: {path}')

Expand Down Expand Up @@ -702,7 +703,7 @@ def mount(
target_mountpoint: Path,
mount_fs: Optional[str] = None,
create_target_mountpoint: bool = True,
options: List[str] = []
options: list[str] = []
) -> None:
if create_target_mountpoint and not target_mountpoint.exists():
target_mountpoint.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -750,8 +751,8 @@ def umount(self, mountpoint: Path, recursive: bool = False) -> None:
debug(f'Unmounting mountpoint: {path}')
SysCommand(cmd + [str(path)])

def detect_pre_mounted_mods(self, base_mountpoint: Path) -> List[DeviceModification]:
part_mods: Dict[Path, List[PartitionModification]] = {}
def detect_pre_mounted_mods(self, base_mountpoint: Path) -> list[DeviceModification]:
part_mods: dict[Path, list[PartitionModification]] = {}

for device in self.devices:
for part_info in device.partition_infos:
Expand All @@ -769,7 +770,7 @@ def detect_pre_mounted_mods(self, base_mountpoint: Path) -> List[DeviceModificat
part_mods[path].append(part_mod)
break

device_mods: List[DeviceModification] = []
device_mods: list[DeviceModification] = []
for device_path, mods in part_mods.items():
device_mod = DeviceModification(self._devices[device_path], False, mods)
device_mods.append(device_mod)
Expand Down
Loading

0 comments on commit 9626965

Please sign in to comment.