Skip to content

Commit 16d8b20

Browse files
authored
Enable possibly-undefined warnings in mypy (#3340)
This commit also fixes the two remaining possibly-undefined warnings.
1 parent bdc260e commit 16d8b20

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

archinstall/lib/installer.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -581,14 +581,16 @@ def set_locale(self, locale_config: LocaleConfiguration) -> bool:
581581
# in the first column of the entry; check for both cases.
582582
entry_re = re.compile(rf'#{lang}(\.{encoding})?{modifier} {encoding}')
583583

584+
lang_value = None
584585
for index, line in enumerate(locale_gen_lines):
585586
if entry_re.match(line):
586587
uncommented_line = line.removeprefix('#')
587588
locale_gen_lines[index] = uncommented_line
588589
locale_gen.write_text(''.join(locale_gen_lines))
589590
lang_value = uncommented_line.split()[0]
590591
break
591-
else:
592+
593+
if lang_value is None:
592594
error(f"Invalid locale: language '{locale_config.sys_lang}', encoding '{locale_config.sys_enc}'")
593595
return False
594596

archinstall/lib/interactions/network_menu.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import ipaddress
4-
from typing import TYPE_CHECKING, override
4+
from typing import TYPE_CHECKING, assert_never, override
55

66
from archinstall.tui.curses_menu import EditMenu, SelectMenu
77
from archinstall.tui.menu_item import MenuItem, MenuItemGroup
@@ -144,6 +144,10 @@ def _edit_iface(self, edit_nic: Nic) -> Nic:
144144
mode = result.get_value()
145145
case ResultType.Reset:
146146
raise ValueError('Unhandled result type')
147+
case ResultType.Skip:
148+
raise ValueError('The mode menu should not be skippable')
149+
case _:
150+
assert_never(result.type_)
147151

148152
if mode == 'IP (static)':
149153
header = str(_('Enter the IP and subnet for {} (example: 192.168.0.5/24): ').format(iface_name)) + '\n'

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ enable_error_code = [
7474
"explicit-override",
7575
"ignore-without-code",
7676
"mutable-override",
77+
"possibly-undefined",
7778
"redundant-expr",
7879
"redundant-self",
7980
"truthy-iterable",

0 commit comments

Comments
 (0)