Enable unreachable code checks in lib/ with mypy (#3521)

This commit is contained in:
correctmost 2025-05-28 10:47:40 +00:00 committed by GitHub
parent 2cf7c85728
commit c2f4d92fd9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 4 additions and 19 deletions

View File

@ -176,20 +176,13 @@ class DiskLayoutConfigurationMenu(AbstractSubMenu[DiskLayoutConfiguration]):
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:

View File

@ -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')),

View File

@ -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

View File

@ -149,5 +149,3 @@ def select_kb_layout(preset: str | None = None) -> str | None:
return preset
case _:
raise ValueError('Unhandled return type')
return None

View File

@ -1490,9 +1490,8 @@ class DiskEncryption:
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 = {

View File

@ -46,7 +46,7 @@ class FormattedOutput:
elif is_dataclass(o):
return asdict(o)
else:
return o.__dict__
return o.__dict__ # type: ignore[unreachable]
@classmethod
def as_table(

View File

@ -237,5 +237,3 @@ def select_profile(
pass
return current_profile
return None

View File

@ -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.*"