From 6ea35bbd84ecff3955237959162396d4ee206d73 Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Wed, 28 May 2025 05:07:21 -0400 Subject: [PATCH] Enable unreachable code checks in lib/ with mypy --- archinstall/lib/disk/disk_menu.py | 9 +-------- archinstall/lib/interactions/network_menu.py | 2 +- archinstall/lib/interactions/system_conf.py | 2 -- archinstall/lib/locale/locale_menu.py | 2 -- archinstall/lib/models/device_model.py | 3 +-- archinstall/lib/output.py | 2 +- archinstall/lib/profile/profile_menu.py | 2 -- pyproject.toml | 1 - 8 files changed, 4 insertions(+), 19 deletions(-) diff --git a/archinstall/lib/disk/disk_menu.py b/archinstall/lib/disk/disk_menu.py index 68d4b376a3..81ce895e64 100644 --- a/archinstall/lib/disk/disk_menu.py +++ b/archinstall/lib/disk/disk_menu.py @@ -176,20 +176,13 @@ def _select_btrfs_snapshots(self, preset: SnapshotConfig | None) -> SnapshotConf alignment=Alignment.CENTER, ).run() - snapshot_type: SnapshotType | None = None - match result.type_: case ResultType.Skip: return preset case ResultType.Reset: return None case ResultType.Selection: - snapshot_type = result.get_value() - - if not snapshot_type: - return None - - return SnapshotConfig(snapshot_type=snapshot_type) + return SnapshotConfig(snapshot_type=result.get_value()) def _prev_disk_layouts(self, item: MenuItem) -> str | None: if not item.value: diff --git a/archinstall/lib/interactions/network_menu.py b/archinstall/lib/interactions/network_menu.py index 405da5c8d8..a3a8b02e6f 100644 --- a/archinstall/lib/interactions/network_menu.py +++ b/archinstall/lib/interactions/network_menu.py @@ -186,7 +186,7 @@ def ask_to_configure_network(preset: NetworkConfiguration | None) -> NetworkConf if preset: group.set_selected_by_value(preset.type) - result = SelectMenu[NetworkConfiguration]( + result = SelectMenu[NicType]( group, alignment=Alignment.CENTER, frame=FrameProperties.min(tr('Network configuration')), diff --git a/archinstall/lib/interactions/system_conf.py b/archinstall/lib/interactions/system_conf.py index ee1e83cec1..025612c6f9 100644 --- a/archinstall/lib/interactions/system_conf.py +++ b/archinstall/lib/interactions/system_conf.py @@ -174,5 +174,3 @@ def ask_for_swap(preset: bool = True) -> bool: return result.item() == MenuItem.yes() case ResultType.Reset: raise ValueError('Unhandled result type') - - return preset diff --git a/archinstall/lib/locale/locale_menu.py b/archinstall/lib/locale/locale_menu.py index bddfac73c3..acefc6d686 100644 --- a/archinstall/lib/locale/locale_menu.py +++ b/archinstall/lib/locale/locale_menu.py @@ -149,5 +149,3 @@ def select_kb_layout(preset: str | None = None) -> str | None: return preset case _: raise ValueError('Unhandled return type') - - return None diff --git a/archinstall/lib/models/device_model.py b/archinstall/lib/models/device_model.py index b030bb3881..8d139e15df 100644 --- a/archinstall/lib/models/device_model.py +++ b/archinstall/lib/models/device_model.py @@ -1490,9 +1490,8 @@ def __post_init__(self) -> None: def should_generate_encryption_file(self, dev: PartitionModification | LvmVolume) -> bool: if isinstance(dev, PartitionModification): return dev in self.partitions and dev.mountpoint != Path('/') - elif isinstance(dev, LvmVolume): + else: return dev in self.lvm_volumes and dev.mountpoint != Path('/') - return False def json(self) -> _DiskEncryptionSerialization: obj: _DiskEncryptionSerialization = { diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py index 1e633865ae..c81b11a611 100644 --- a/archinstall/lib/output.py +++ b/archinstall/lib/output.py @@ -46,7 +46,7 @@ def _get_values( elif is_dataclass(o): return asdict(o) else: - return o.__dict__ + return o.__dict__ # type: ignore[unreachable] @classmethod def as_table( diff --git a/archinstall/lib/profile/profile_menu.py b/archinstall/lib/profile/profile_menu.py index 00ad1017b8..5f4597c0ac 100644 --- a/archinstall/lib/profile/profile_menu.py +++ b/archinstall/lib/profile/profile_menu.py @@ -237,5 +237,3 @@ def select_profile( pass return current_profile - - return None diff --git a/pyproject.toml b/pyproject.toml index df5cfbe16b..6a6d023964 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,7 +100,6 @@ module = "archinstall.lib.*" disallow_incomplete_defs = false disallow_untyped_defs = false warn_return_any = false -warn_unreachable = false [[tool.mypy.overrides]] module = "archinstall.lib.disk.*"