Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2023-05-04 00:36:46 +1000
committerGitHub <noreply@github.com>2023-05-03 16:36:46 +0200
commitec4ecbcb7a839ab06b739f01ce42bfd18376c620 (patch)
treeb617783f2d7cb4d4bf32690590859e68666bf3d4 /archinstall/lib/disk
parente78ddb03e1bbc46e59fd6a9889699b12808d0fec (diff)
Full mypy compliance and small fixes (#1777)
* Fix mypy compliance --------- Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
Diffstat (limited to 'archinstall/lib/disk')
-rw-r--r--archinstall/lib/disk/device_handler.py18
-rw-r--r--archinstall/lib/disk/device_model.py2
-rw-r--r--archinstall/lib/disk/fido.py9
3 files changed, 15 insertions, 14 deletions
diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py
index ba325cda..8f92cf3b 100644
--- a/archinstall/lib/disk/device_handler.py
+++ b/archinstall/lib/disk/device_handler.py
@@ -269,13 +269,13 @@ class DeviceHandler(object):
# partition will be encrypted
if enc_conf is not None and part_mod in enc_conf.partitions:
self._perform_enc_formatting(
- part_mod.real_dev_path,
+ part_mod.safe_dev_path,
part_mod.mapper_name,
part_mod.fs_type,
enc_conf
)
else:
- self._perform_formatting(part_mod.fs_type, part_mod.real_dev_path)
+ self._perform_formatting(part_mod.fs_type, part_mod.safe_dev_path)
def _perform_partitioning(
self,
@@ -287,11 +287,11 @@ class DeviceHandler(object):
# when we require a delete and the partition to be (re)created
# already exists then we have to delete it first
if requires_delete and part_mod.status in [ModificationStatus.Modify, ModificationStatus.Delete]:
- log(f'Delete existing partition: {part_mod.real_dev_path}', level=logging.INFO)
- part_info = self.find_partition(part_mod.real_dev_path)
+ log(f'Delete existing partition: {part_mod.safe_dev_path}', level=logging.INFO)
+ part_info = self.find_partition(part_mod.safe_dev_path)
if not part_info:
- raise DiskError(f'No partition for dev path found: {part_mod.real_dev_path}')
+ raise DiskError(f'No partition for dev path found: {part_mod.safe_dev_path}')
disk.deletePartition(part_info.partition)
disk.commit()
@@ -375,7 +375,7 @@ class DeviceHandler(object):
part_mod: PartitionModification,
enc_conf: Optional['DiskEncryption'] = None
):
- log(f'Creating subvolumes: {part_mod.real_dev_path}', level=logging.INFO)
+ log(f'Creating subvolumes: {part_mod.safe_dev_path}', level=logging.INFO)
luks_handler = None
@@ -385,7 +385,7 @@ class DeviceHandler(object):
raise ValueError('No device path specified for modification')
luks_handler = self.unlock_luks2_dev(
- part_mod.real_dev_path,
+ part_mod.safe_dev_path,
part_mod.mapper_name,
enc_conf.encryption_password
)
@@ -395,7 +395,7 @@ class DeviceHandler(object):
self.mount(luks_handler.mapper_dev, self._TMP_BTRFS_MOUNT, create_target_mountpoint=True)
else:
- self.mount(part_mod.real_dev_path, self._TMP_BTRFS_MOUNT, create_target_mountpoint=True)
+ self.mount(part_mod.safe_dev_path, self._TMP_BTRFS_MOUNT, create_target_mountpoint=True)
for sub_vol in part_mod.btrfs_subvols:
log(f'Creating subvolume: {sub_vol.name}', level=logging.DEBUG)
@@ -419,7 +419,7 @@ class DeviceHandler(object):
self.umount(luks_handler.mapper_dev)
luks_handler.lock()
else:
- self.umount(part_mod.real_dev_path)
+ self.umount(part_mod.safe_dev_path)
def unlock_luks2_dev(self, dev_path: Path, mapper_name: str, enc_password: str) -> Luks2:
luks_handler = Luks2(dev_path, mapper_name=mapper_name, password=enc_password)
diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py
index 0270a4dd..987a1e8a 100644
--- a/archinstall/lib/disk/device_model.py
+++ b/archinstall/lib/disk/device_model.py
@@ -603,7 +603,7 @@ class PartitionModification:
return ''
@property
- def real_dev_path(self) -> Path:
+ def safe_dev_path(self) -> Path:
if self.dev_path is None:
raise ValueError('Device path was not set')
return self.dev_path
diff --git a/archinstall/lib/disk/fido.py b/archinstall/lib/disk/fido.py
index 436be4d4..2a53b551 100644
--- a/archinstall/lib/disk/fido.py
+++ b/archinstall/lib/disk/fido.py
@@ -2,7 +2,8 @@ from __future__ import annotations
import getpass
import logging
-from typing import List
+from pathlib import Path
+from typing import List, Optional
from .device_model import PartitionModification, Fido2Device
from ..general import SysCommand, SysCommandWorker, clear_vt100_escape_codes
@@ -36,12 +37,12 @@ class Fido2:
# to prevent continous reloading which will slow
# down moving the cursor in the menu
if not cls._loaded or reload:
- ret = SysCommand(f"systemd-cryptenroll --fido2-device=list").decode('UTF-8')
+ ret: Optional[str] = SysCommand(f"systemd-cryptenroll --fido2-device=list").decode('UTF-8')
if not ret:
log('Unable to retrieve fido2 devices', level=logging.ERROR)
return []
- fido_devices = clear_vt100_escape_codes(ret)
+ fido_devices: str = clear_vt100_escape_codes(ret) # type: ignore
manufacturer_pos = 0
product_pos = 0
@@ -58,7 +59,7 @@ class Fido2:
product = line[product_pos:]
devices.append(
- Fido2Device(path, manufacturer, product)
+ Fido2Device(Path(path), manufacturer, product)
)
cls._loaded = True