Enable stricter mypy definition checks in archinstall/lib/ (#3573)

This commit is contained in:
correctmost 2025-06-03 21:30:14 +00:00 committed by GitHub
parent 557e1cac0d
commit 2843d01600
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 11 deletions

View File

@ -99,7 +99,7 @@ class Boot:
return self.session.is_alive()
def SysCommand(self, cmd: list[str], *args, **kwargs) -> SysCommand:
def SysCommand(self, cmd: list[str], *args, **kwargs) -> SysCommand: # type: ignore[no-untyped-def]
if cmd[0][0] != '/' and cmd[0][:2] != './':
# This check is also done in SysCommand & SysCommandWorker.
# However, that check is done for `machinectl` and not for our chroot command.
@ -109,7 +109,7 @@ class Boot:
return SysCommand(['systemd-run', f'--machine={self.container_name}', '--pty', *cmd], *args, **kwargs)
def SysCommandWorker(self, cmd: list[str], *args, **kwargs) -> SysCommandWorker:
def SysCommandWorker(self, cmd: list[str], *args, **kwargs) -> SysCommandWorker: # type: ignore[no-untyped-def]
if cmd[0][0] != '/' and cmd[0][:2] != './':
cmd[0] = locate_binary(cmd[0])

View File

@ -205,7 +205,7 @@ class GlobalMenu(AbstractMenu[None]):
save_config(self._arch_config)
def _missing_configs(self) -> list[str]:
def check(s) -> bool:
def check(s: str) -> bool:
item = self._item_group.find_by_key(s)
return item.has_value()
@ -227,6 +227,7 @@ class GlobalMenu(AbstractMenu[None]):
tr('Either root-password or at least 1 user with sudo privileges must be specified'),
)
elif item.mandatory:
assert item.key is not None
if not check(item.key):
missing.add(item.text)
@ -486,7 +487,7 @@ class GlobalMenu(AbstractMenu[None]):
return bootloader
def _select_profile(self, current_profile: ProfileConfiguration | None):
def _select_profile(self, current_profile: ProfileConfiguration | None) -> ProfileConfiguration | None:
from .profile.profile_menu import ProfileMenu
profile_config = ProfileMenu(preset=current_profile).run()

View File

@ -88,6 +88,7 @@ class MirrorStatusEntryV3(BaseModel):
"""
if self._latency is None:
debug(f'Checking latency for {self.url}')
assert self._hostname is not None
self._latency = ping(self._hostname, timeout=2)
debug(f' latency: {self._latency}')

View File

@ -163,7 +163,7 @@ def build_icmp(payload: bytes) -> bytes:
return struct.pack('!BBHHH', 8, 0, checksum, 0, 1) + payload
def ping(hostname, timeout: int = 5) -> int:
def ping(hostname: str, timeout: int = 5) -> int:
watchdog = select.epoll()
started = time.time()
random_identifier = f'archinstall-{random.randint(1000, 9999)}'.encode()

View File

@ -39,7 +39,7 @@ class Pacman:
return SysCommand(f'{default_cmd} {args}')
def ask(self, error_message: str, bail_message: str, func: Callable, *args, **kwargs) -> None: # type: ignore[type-arg]
def ask(self, error_message: str, bail_message: str, func: Callable, *args, **kwargs) -> None: # type: ignore[no-untyped-def, type-arg]
while True:
try:
func(*args, **kwargs)

View File

@ -97,8 +97,6 @@ disallow_any_explicit = true
[[tool.mypy.overrides]]
module = "archinstall.lib.*"
disallow_incomplete_defs = false
disallow_untyped_defs = false
warn_return_any = false
[[tool.mypy.overrides]]
@ -119,9 +117,6 @@ disallow_any_explicit = true
module = "archinstall.lib.utils"
disallow_any_explicit = true
[[tool.mypy.overrides]]
module = "archinstall.tui.*"
[[tool.mypy.overrides]]
module = [
"parted",