Skip to content

Commit

Permalink
Fix most mypy errors in archinstall/scripts/, docs/, and the __init__…
Browse files Browse the repository at this point in the history
… file (#2641)
  • Loading branch information
correctmost authored Aug 28, 2024
1 parent 0601708 commit 62d66e1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
16 changes: 8 additions & 8 deletions archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
parser = ArgumentParser()


def define_arguments():
def define_arguments() -> None:
"""
Define which explicit arguments do we allow.
Refer to https://docs.python.org/3/library/argparse.html for documentation and
Expand Down Expand Up @@ -213,7 +213,7 @@ def get_arguments() -> Dict[str, Any]:
return config


def load_config():
def load_config() -> None:
"""
refine and set some arguments. Formerly at the scripts
"""
Expand Down Expand Up @@ -263,7 +263,7 @@ def load_config():
)


def post_process_arguments(arguments):
def post_process_arguments(arguments: dict[str, Any]) -> None:
storage['arguments'] = arguments
if mountpoint := arguments.get('mount_point', None):
storage['MOUNT_POINT'] = Path(mountpoint)
Expand All @@ -285,11 +285,11 @@ def post_process_arguments(arguments):

# @archinstall.plugin decorator hook to programmatically add
# plugins in runtime. Useful in profiles_bck and other things.
def plugin(f, *args, **kwargs):
def plugin(f, *args, **kwargs) -> None:
plugins[f.__name__] = f


def _check_new_version():
def _check_new_version() -> None:
info("Checking version...")

try:
Expand All @@ -312,7 +312,7 @@ def _check_new_version():
time.sleep(3)


def main():
def main() -> None:
"""
This can either be run as the compiled and installed application: python setup.py install
OR straight as a module: python -m archinstall
Expand All @@ -331,7 +331,7 @@ def main():
importlib.import_module(mod_name)


def _shutdown_curses():
def _shutdown_curses() -> None:
try:
curses.nocbreak()

Expand All @@ -349,7 +349,7 @@ def _shutdown_curses():
pass


def run_as_a_module():
def run_as_a_module() -> None:
exc = None

try:
Expand Down
4 changes: 2 additions & 2 deletions archinstall/scripts/guided.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
exit(0)


def ask_user_questions():
def ask_user_questions() -> None:
"""
First, we'll ask the user for a bunch of user input.
Not until we're satisfied with what we want to install
Expand Down Expand Up @@ -97,7 +97,7 @@ def ask_user_questions():
global_menu.run()


def perform_installation(mountpoint: Path):
def perform_installation(mountpoint: Path) -> None:
"""
Performs the installation steps on a block device.
Only requirement is that the block devices are
Expand Down
6 changes: 3 additions & 3 deletions archinstall/scripts/minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
info(" - Optional systemd network via --network")


def perform_installation(mountpoint: Path):
def perform_installation(mountpoint: Path) -> None:
disk_config: disk.DiskLayoutConfiguration = archinstall.arguments['disk_config']
disk_encryption: disk.DiskEncryption = archinstall.arguments.get('disk_encryption', None)

Expand Down Expand Up @@ -58,7 +58,7 @@ def perform_installation(mountpoint: Path):
info(" * devel (password: devel)")


def prompt_disk_layout():
def prompt_disk_layout() -> None:
fs_type = None
if filesystem := archinstall.arguments.get('filesystem', None):
fs_type = disk.FilesystemType(filesystem)
Expand All @@ -72,7 +72,7 @@ def prompt_disk_layout():
)


def parse_disk_encryption():
def parse_disk_encryption() -> None:
if enc_password := archinstall.arguments.get('!encryption-password', None):
modification: List[disk.DeviceModification] = archinstall.arguments['disk_config']
partitions: List[disk.PartitionModification] = []
Expand Down
4 changes: 2 additions & 2 deletions archinstall/scripts/only_hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from archinstall.lib import disk


def ask_user_questions():
def ask_user_questions() -> None:
global_menu = archinstall.GlobalMenu(data_store=archinstall.arguments)

global_menu.enable('archinstall-language')
Expand All @@ -23,7 +23,7 @@ def ask_user_questions():
global_menu.run()


def perform_installation(mountpoint: Path):
def perform_installation(mountpoint: Path) -> None:
"""
Performs the installation steps on a block device.
Only requirement is that the block devices are
Expand Down
10 changes: 5 additions & 5 deletions archinstall/scripts/swiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SetupMenu(GlobalMenu):
def __init__(self, storage_area: Dict[str, Any]):
super().__init__(data_store=storage_area)

def setup_selection_menu_options(self):
def setup_selection_menu_options(self) -> None:
super().setup_selection_menu_options()

self._menu_options['mode'] = menu.Selector(
Expand All @@ -61,7 +61,7 @@ def setup_selection_menu_options(self):
self.enable('continue')
self.enable('abort')

def exit_callback(self):
def exit_callback(self) -> None:
if self._data_store.get('mode', None):
archinstall.arguments['mode'] = self._data_store['mode']
info(f"Archinstall will execute under {archinstall.arguments['mode']} mode")
Expand All @@ -76,7 +76,7 @@ def __init__(
self._execution_mode = exec_mode
super().__init__(data_store)

def setup_selection_menu_options(self):
def setup_selection_menu_options(self) -> None:
super().setup_selection_menu_options()

options_list = []
Expand Down Expand Up @@ -130,7 +130,7 @@ def setup_selection_menu_options(self):
self.enable(entry)


def ask_user_questions(exec_mode: ExecutionMode = ExecutionMode.Full):
def ask_user_questions(exec_mode: ExecutionMode = ExecutionMode.Full) -> None:
"""
First, we'll ask the user for a bunch of user input.
Not until we're satisfied with what we want to install
Expand Down Expand Up @@ -163,7 +163,7 @@ def ask_user_questions(exec_mode: ExecutionMode = ExecutionMode.Full):
menu.run()


def perform_installation(mountpoint: Path, exec_mode: ExecutionMode):
def perform_installation(mountpoint: Path, exec_mode: ExecutionMode) -> None:
disk_config: disk.DiskLayoutConfiguration = archinstall.arguments['disk_config']
disk_encryption: disk.DiskEncryption = archinstall.arguments.get('disk_encryption', None)

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
sys.path.insert(0, os.path.abspath('..'))


def process_docstring(app, what, name, obj, options, lines):
def process_docstring(app, what, name, obj, options, lines) -> None:
spaces_pat = re.compile(r"( {8})")
ll = [spaces_pat.sub(" ", line) for line in lines]
lines[:] = ll


def setup(app):
def setup(app) -> None:
app.connect('autodoc-process-docstring', process_docstring)


Expand Down

0 comments on commit 62d66e1

Please sign in to comment.