Fix most mypy errors in archinstall/scripts/, docs/, and the __init__ file (#2641)

This commit is contained in:
correctmost 2024-08-28 10:24:08 -04:00 committed by GitHub
parent 0601708a02
commit 62d66e1caf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 22 additions and 22 deletions

View File

@ -63,7 +63,7 @@ debug(f"Disk states before installing: {disk.disk_layouts()}")
parser = ArgumentParser() parser = ArgumentParser()
def define_arguments(): def define_arguments() -> None:
""" """
Define which explicit arguments do we allow. Define which explicit arguments do we allow.
Refer to https://docs.python.org/3/library/argparse.html for documentation and Refer to https://docs.python.org/3/library/argparse.html for documentation and
@ -213,7 +213,7 @@ def get_arguments() -> Dict[str, Any]:
return config return config
def load_config(): def load_config() -> None:
""" """
refine and set some arguments. Formerly at the scripts refine and set some arguments. Formerly at the scripts
""" """
@ -263,7 +263,7 @@ def load_config():
) )
def post_process_arguments(arguments): def post_process_arguments(arguments: dict[str, Any]) -> None:
storage['arguments'] = arguments storage['arguments'] = arguments
if mountpoint := arguments.get('mount_point', None): if mountpoint := arguments.get('mount_point', None):
storage['MOUNT_POINT'] = Path(mountpoint) storage['MOUNT_POINT'] = Path(mountpoint)
@ -285,11 +285,11 @@ post_process_arguments(arguments)
# @archinstall.plugin decorator hook to programmatically add # @archinstall.plugin decorator hook to programmatically add
# plugins in runtime. Useful in profiles_bck and other things. # 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 plugins[f.__name__] = f
def _check_new_version(): def _check_new_version() -> None:
info("Checking version...") info("Checking version...")
try: try:
@ -312,7 +312,7 @@ def _check_new_version():
time.sleep(3) time.sleep(3)
def main(): def main() -> None:
""" """
This can either be run as the compiled and installed application: python setup.py install This can either be run as the compiled and installed application: python setup.py install
OR straight as a module: python -m archinstall OR straight as a module: python -m archinstall
@ -331,7 +331,7 @@ def main():
importlib.import_module(mod_name) importlib.import_module(mod_name)
def _shutdown_curses(): def _shutdown_curses() -> None:
try: try:
curses.nocbreak() curses.nocbreak()
@ -349,7 +349,7 @@ def _shutdown_curses():
pass pass
def run_as_a_module(): def run_as_a_module() -> None:
exc = None exc = None
try: try:

View File

@ -23,7 +23,7 @@ if archinstall.arguments.get('help'):
exit(0) exit(0)
def ask_user_questions(): def ask_user_questions() -> None:
""" """
First, we'll ask the user for a bunch of user input. First, we'll ask the user for a bunch of user input.
Not until we're satisfied with what we want to install Not until we're satisfied with what we want to install
@ -97,7 +97,7 @@ def ask_user_questions():
global_menu.run() global_menu.run()
def perform_installation(mountpoint: Path): def perform_installation(mountpoint: Path) -> None:
""" """
Performs the installation steps on a block device. Performs the installation steps on a block device.
Only requirement is that the block devices are Only requirement is that the block devices are

View File

@ -23,7 +23,7 @@ if archinstall.arguments.get('help', None):
info(" - Optional systemd network via --network") 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_config: disk.DiskLayoutConfiguration = archinstall.arguments['disk_config']
disk_encryption: disk.DiskEncryption = archinstall.arguments.get('disk_encryption', None) disk_encryption: disk.DiskEncryption = archinstall.arguments.get('disk_encryption', None)
@ -58,7 +58,7 @@ def perform_installation(mountpoint: Path):
info(" * devel (password: devel)") info(" * devel (password: devel)")
def prompt_disk_layout(): def prompt_disk_layout() -> None:
fs_type = None fs_type = None
if filesystem := archinstall.arguments.get('filesystem', None): if filesystem := archinstall.arguments.get('filesystem', None):
fs_type = disk.FilesystemType(filesystem) fs_type = disk.FilesystemType(filesystem)
@ -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): if enc_password := archinstall.arguments.get('!encryption-password', None):
modification: List[disk.DeviceModification] = archinstall.arguments['disk_config'] modification: List[disk.DeviceModification] = archinstall.arguments['disk_config']
partitions: List[disk.PartitionModification] = [] partitions: List[disk.PartitionModification] = []

View File

@ -7,7 +7,7 @@ from archinstall.lib.configuration import ConfigurationOutput
from archinstall.lib import disk from archinstall.lib import disk
def ask_user_questions(): def ask_user_questions() -> None:
global_menu = archinstall.GlobalMenu(data_store=archinstall.arguments) global_menu = archinstall.GlobalMenu(data_store=archinstall.arguments)
global_menu.enable('archinstall-language') global_menu.enable('archinstall-language')
@ -23,7 +23,7 @@ def ask_user_questions():
global_menu.run() global_menu.run()
def perform_installation(mountpoint: Path): def perform_installation(mountpoint: Path) -> None:
""" """
Performs the installation steps on a block device. Performs the installation steps on a block device.
Only requirement is that the block devices are Only requirement is that the block devices are

View File

@ -42,7 +42,7 @@ class SetupMenu(GlobalMenu):
def __init__(self, storage_area: Dict[str, Any]): def __init__(self, storage_area: Dict[str, Any]):
super().__init__(data_store=storage_area) super().__init__(data_store=storage_area)
def setup_selection_menu_options(self): def setup_selection_menu_options(self) -> None:
super().setup_selection_menu_options() super().setup_selection_menu_options()
self._menu_options['mode'] = menu.Selector( self._menu_options['mode'] = menu.Selector(
@ -61,7 +61,7 @@ class SetupMenu(GlobalMenu):
self.enable('continue') self.enable('continue')
self.enable('abort') self.enable('abort')
def exit_callback(self): def exit_callback(self) -> None:
if self._data_store.get('mode', None): if self._data_store.get('mode', None):
archinstall.arguments['mode'] = self._data_store['mode'] archinstall.arguments['mode'] = self._data_store['mode']
info(f"Archinstall will execute under {archinstall.arguments['mode']} mode") info(f"Archinstall will execute under {archinstall.arguments['mode']} mode")
@ -76,7 +76,7 @@ class SwissMainMenu(GlobalMenu):
self._execution_mode = exec_mode self._execution_mode = exec_mode
super().__init__(data_store) super().__init__(data_store)
def setup_selection_menu_options(self): def setup_selection_menu_options(self) -> None:
super().setup_selection_menu_options() super().setup_selection_menu_options()
options_list = [] options_list = []
@ -130,7 +130,7 @@ class SwissMainMenu(GlobalMenu):
self.enable(entry) 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. First, we'll ask the user for a bunch of user input.
Not until we're satisfied with what we want to install Not until we're satisfied with what we want to install
@ -163,7 +163,7 @@ def ask_user_questions(exec_mode: ExecutionMode = ExecutionMode.Full):
menu.run() 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_config: disk.DiskLayoutConfiguration = archinstall.arguments['disk_config']
disk_encryption: disk.DiskEncryption = archinstall.arguments.get('disk_encryption', None) disk_encryption: disk.DiskEncryption = archinstall.arguments.get('disk_encryption', None)

View File

@ -5,13 +5,13 @@ import sys
sys.path.insert(0, os.path.abspath('..')) 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})") spaces_pat = re.compile(r"( {8})")
ll = [spaces_pat.sub(" ", line) for line in lines] ll = [spaces_pat.sub(" ", line) for line in lines]
lines[:] = ll lines[:] = ll
def setup(app): def setup(app) -> None:
app.connect('autodoc-process-docstring', process_docstring) app.connect('autodoc-process-docstring', process_docstring)