Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/systemd.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2022-01-06 22:01:15 +0100
committerGitHub <noreply@github.com>2022-01-06 22:01:15 +0100
commite32cf71ae7dacbf9674262705cb2e8e1a5a2d206 (patch)
treed33e6202d10813221a9935dcdc49145f6ffca83e /archinstall/lib/systemd.py
parent015cd2a59fbdf3316ddfb7546b884157ad00c7fe (diff)
Added type annotations to all functions (#845)
* Added type annotations for 1/5 of the files. There's bound to be some issues with type miss-match, will sort that out later. * Added type hints for 4/5 of the code * Added type hints for 4.7/5 of the code * Added type hints for 5/5 of the code base * Split the linters into individual files This should help with more clearly show which runner is breaking since they don't share a single common name any longer. Also moved mypy settings into pyproject.toml * Fixed some of the last flake8 issues * Missing parameter * Fixed invalid lookahead types * __future__ had to be at the top * Fixed last flake8 issues
Diffstat (limited to 'archinstall/lib/systemd.py')
-rw-r--r--archinstall/lib/systemd.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/archinstall/lib/systemd.py b/archinstall/lib/systemd.py
index c3beafc0..74229fae 100644
--- a/archinstall/lib/systemd.py
+++ b/archinstall/lib/systemd.py
@@ -1,5 +1,6 @@
import logging
import time
+from typing import Interator
from .exceptions import SysCallError
from .general import SysCommand, SysCommandWorker, locate_binary
from .installer import Installer
@@ -8,14 +9,14 @@ from .storage import storage
class Ini:
- def __init__(self, *args, **kwargs):
+ def __init__(self, *args :str, **kwargs :str):
"""
Limited INI handler for now.
Supports multiple keywords through dictionary list items.
"""
self.kwargs = kwargs
- def __str__(self):
+ def __str__(self) -> str:
result = ''
first_row_done = False
for top_level in self.kwargs:
@@ -54,7 +55,7 @@ class Boot:
self.session = None
self.ready = False
- def __enter__(self):
+ def __enter__(self) -> 'Boot':
if (existing_session := storage.get('active_boot', None)) and existing_session.instance != self.instance:
raise KeyError("Archinstall only supports booting up one instance, and a active session is already active and it is not this one.")
@@ -81,7 +82,7 @@ class Boot:
storage['active_boot'] = self
return self
- def __exit__(self, *args, **kwargs):
+ def __exit__(self, *args :str, **kwargs :str) -> None:
# b''.join(sys_command('sync')) # No need to, since the underlying fs() object will call sync.
# TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager
@@ -98,24 +99,24 @@ class Boot:
else:
raise SysCallError(f"Could not shut down temporary boot of {self.instance}: {shutdown}", exit_code=shutdown.exit_code)
- def __iter__(self):
+ def __iter__(self) -> Interator[str]:
if self.session:
for value in self.session:
yield value
- def __contains__(self, key: bytes):
+ def __contains__(self, key: bytes) -> bool:
if self.session is None:
return False
return key in self.session
- def is_alive(self):
+ def is_alive(self) -> bool:
if self.session is None:
return False
return self.session.is_alive()
- def SysCommand(self, cmd: list, *args, **kwargs):
+ def SysCommand(self, cmd: list, *args, **kwargs) -> SysCommand:
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.
@@ -125,7 +126,7 @@ class Boot:
return SysCommand(["systemd-run", f"--machine={self.container_name}", "--pty", *cmd], *args, **kwargs)
- def SysCommandWorker(self, cmd: list, *args, **kwargs):
+ def SysCommandWorker(self, cmd: list, *args, **kwargs) -> SysCommandWorker:
if cmd[0][0] != '/' and cmd[0][:2] != './':
cmd[0] = locate_binary(cmd[0])