Enable stricter mypy definition checks in archinstall/lib/ (#3573)
This commit is contained in:
parent
557e1cac0d
commit
2843d01600
|
|
@ -99,7 +99,7 @@ class Boot:
|
||||||
|
|
||||||
return self.session.is_alive()
|
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] != './':
|
if cmd[0][0] != '/' and cmd[0][:2] != './':
|
||||||
# This check is also done in SysCommand & SysCommandWorker.
|
# This check is also done in SysCommand & SysCommandWorker.
|
||||||
# However, that check is done for `machinectl` and not for our chroot command.
|
# 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)
|
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] != './':
|
if cmd[0][0] != '/' and cmd[0][:2] != './':
|
||||||
cmd[0] = locate_binary(cmd[0])
|
cmd[0] = locate_binary(cmd[0])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ class GlobalMenu(AbstractMenu[None]):
|
||||||
save_config(self._arch_config)
|
save_config(self._arch_config)
|
||||||
|
|
||||||
def _missing_configs(self) -> list[str]:
|
def _missing_configs(self) -> list[str]:
|
||||||
def check(s) -> bool:
|
def check(s: str) -> bool:
|
||||||
item = self._item_group.find_by_key(s)
|
item = self._item_group.find_by_key(s)
|
||||||
return item.has_value()
|
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'),
|
tr('Either root-password or at least 1 user with sudo privileges must be specified'),
|
||||||
)
|
)
|
||||||
elif item.mandatory:
|
elif item.mandatory:
|
||||||
|
assert item.key is not None
|
||||||
if not check(item.key):
|
if not check(item.key):
|
||||||
missing.add(item.text)
|
missing.add(item.text)
|
||||||
|
|
||||||
|
|
@ -486,7 +487,7 @@ class GlobalMenu(AbstractMenu[None]):
|
||||||
|
|
||||||
return bootloader
|
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
|
from .profile.profile_menu import ProfileMenu
|
||||||
|
|
||||||
profile_config = ProfileMenu(preset=current_profile).run()
|
profile_config = ProfileMenu(preset=current_profile).run()
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ class MirrorStatusEntryV3(BaseModel):
|
||||||
"""
|
"""
|
||||||
if self._latency is None:
|
if self._latency is None:
|
||||||
debug(f'Checking latency for {self.url}')
|
debug(f'Checking latency for {self.url}')
|
||||||
|
assert self._hostname is not None
|
||||||
self._latency = ping(self._hostname, timeout=2)
|
self._latency = ping(self._hostname, timeout=2)
|
||||||
debug(f' latency: {self._latency}')
|
debug(f' latency: {self._latency}')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ def build_icmp(payload: bytes) -> bytes:
|
||||||
return struct.pack('!BBHHH', 8, 0, checksum, 0, 1) + payload
|
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()
|
watchdog = select.epoll()
|
||||||
started = time.time()
|
started = time.time()
|
||||||
random_identifier = f'archinstall-{random.randint(1000, 9999)}'.encode()
|
random_identifier = f'archinstall-{random.randint(1000, 9999)}'.encode()
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class Pacman:
|
||||||
|
|
||||||
return SysCommand(f'{default_cmd} {args}')
|
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:
|
while True:
|
||||||
try:
|
try:
|
||||||
func(*args, **kwargs)
|
func(*args, **kwargs)
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,6 @@ disallow_any_explicit = true
|
||||||
|
|
||||||
[[tool.mypy.overrides]]
|
[[tool.mypy.overrides]]
|
||||||
module = "archinstall.lib.*"
|
module = "archinstall.lib.*"
|
||||||
disallow_incomplete_defs = false
|
|
||||||
disallow_untyped_defs = false
|
|
||||||
warn_return_any = false
|
warn_return_any = false
|
||||||
|
|
||||||
[[tool.mypy.overrides]]
|
[[tool.mypy.overrides]]
|
||||||
|
|
@ -119,9 +117,6 @@ disallow_any_explicit = true
|
||||||
module = "archinstall.lib.utils"
|
module = "archinstall.lib.utils"
|
||||||
disallow_any_explicit = true
|
disallow_any_explicit = true
|
||||||
|
|
||||||
[[tool.mypy.overrides]]
|
|
||||||
module = "archinstall.tui.*"
|
|
||||||
|
|
||||||
[[tool.mypy.overrides]]
|
[[tool.mypy.overrides]]
|
||||||
module = [
|
module = [
|
||||||
"parted",
|
"parted",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue