Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel <blackrabbit256@gmail.com>2022-03-01 01:45:08 +1100
committerGitHub <noreply@github.com>2022-02-28 15:45:08 +0100
commitfa87d85708331ad45f28906217f94937bae474fe (patch)
tree2c0dec90275a7c262cd99db5490215f7aff51694
parent0fed839110983f024edda88c10d9cd55be9ae122 (diff)
Fix (some) mypy things (#996)
* Fix mypy things * Fix flake8 Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
-rw-r--r--archinstall/lib/disk/filesystem.py1
-rw-r--r--archinstall/lib/disk/helpers.py8
-rw-r--r--archinstall/lib/installer.py6
-rw-r--r--archinstall/lib/menu/menu.py6
-rw-r--r--archinstall/lib/profiles.py7
-rw-r--r--archinstall/lib/storage.py4
-rw-r--r--archinstall/lib/translation.py5
-rw-r--r--archinstall/lib/user_interaction.py5
8 files changed, 31 insertions, 11 deletions
diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py
index 4f1b4217..25e251c2 100644
--- a/archinstall/lib/disk/filesystem.py
+++ b/archinstall/lib/disk/filesystem.py
@@ -7,6 +7,7 @@ from typing import Optional, Dict, Any, TYPE_CHECKING
# https://stackoverflow.com/a/39757388/929999
if TYPE_CHECKING:
from .blockdevice import BlockDevice
+ _: Any
from .partition import Partition
from .validators import valid_fs_type
diff --git a/archinstall/lib/disk/helpers.py b/archinstall/lib/disk/helpers.py
index afaf9e5e..eae618fb 100644
--- a/archinstall/lib/disk/helpers.py
+++ b/archinstall/lib/disk/helpers.py
@@ -1,7 +1,7 @@
from __future__ import annotations
import json
import logging
-import os
+import os # type: ignore
import pathlib
import re
import time
@@ -10,7 +10,7 @@ from typing import Union, List, Iterator, Dict, Optional, Any, TYPE_CHECKING
# https://stackoverflow.com/a/39757388/929999
if TYPE_CHECKING:
from .partition import Partition
-
+
from .blockdevice import BlockDevice
from .dmcryptdev import DMCryptDev
from .mapperdev import MapperDev
@@ -206,7 +206,7 @@ def all_disks() -> List[BlockDevice]:
log(f"[Deprecated] archinstall.all_disks() is deprecated. Use archinstall.all_blockdevices() with the appropriate filters instead.", level=logging.WARNING, fg="yellow")
return all_blockdevices(partitions=False, mappers=False)
-def all_blockdevices(mappers=False, partitions=False, error=False) -> List[BlockDevice, Partition]:
+def all_blockdevices(mappers=False, partitions=False, error=False) -> Dict[str, Any]:
"""
Returns BlockDevice() and Partition() objects for all available devices.
"""
@@ -237,7 +237,7 @@ def all_blockdevices(mappers=False, partitions=False, error=False) -> List[Block
raise error
information = enrich_blockdevice_information(information)
-
+
for path, path_info in information.items():
if path_info.get('DMCRYPT_NAME'):
instances[path] = DMCryptDev(dev_path=path)
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 6f9a1071..cf643b27 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -8,7 +8,7 @@ import pathlib
import subprocess
import glob
from types import ModuleType
-from typing import Union, Dict, Any, List, Optional, Iterator, Mapping
+from typing import Union, Dict, Any, List, Optional, Iterator, Mapping, TYPE_CHECKING
from .disk import get_partitions_in_use, Partition
from .general import SysCommand, generate_password
from .hardware import has_uefi, is_vm, cpu_vendor
@@ -24,6 +24,10 @@ from .disk.btrfs import manage_btrfs_subvolumes
from .disk.partition import get_mount_fs_type
from .exceptions import DiskError, ServiceException, RequirementError, HardwareIncompatibilityError, SysCallError
+if TYPE_CHECKING:
+ _: Any
+
+
# Any package that the Installer() is responsible for (optional and the default ones)
__packages__ = ["base", "base-devel", "linux-firmware", "linux", "linux-lts", "linux-zen", "linux-hardened"]
diff --git a/archinstall/lib/menu/menu.py b/archinstall/lib/menu/menu.py
index 962dcc4d..1d5d497e 100644
--- a/archinstall/lib/menu/menu.py
+++ b/archinstall/lib/menu/menu.py
@@ -1,4 +1,4 @@
-from typing import Dict, List, Union, Any
+from typing import Dict, List, Union, Any, TYPE_CHECKING
from archinstall.lib.menu.simple_menu import TerminalMenu
from ..exceptions import RequirementError
@@ -8,6 +8,10 @@ from collections.abc import Iterable
import sys
import logging
+if TYPE_CHECKING:
+ _: Any
+
+
class Menu(TerminalMenu):
def __init__(
self,
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index 4295fa8f..65a30b0b 100644
--- a/archinstall/lib/profiles.py
+++ b/archinstall/lib/profiles.py
@@ -9,11 +9,12 @@ import sys
import urllib.error
import urllib.parse
import urllib.request
-from typing import Optional, Dict, Union, TYPE_CHECKING
+from typing import Optional, Dict, Union, TYPE_CHECKING, Any
from types import ModuleType
# https://stackoverflow.com/a/39757388/929999
if TYPE_CHECKING:
from .installer import Installer
+ _: Any
from .general import multisplit
from .networking import list_interfaces
@@ -123,7 +124,7 @@ class Script:
self.installer = installer # TODO: Appears not to be used anymore?
self.converted_path = None
self.spec = None
- self.examples = None
+ self.examples = {}
self.namespace = os.path.splitext(os.path.basename(self.path))[0]
self.original_namespace = self.namespace
@@ -197,7 +198,7 @@ class Script:
class Profile(Script):
- def __init__(self, installer :Installer, path :str):
+ def __init__(self, installer :Optional[Installer], path :str):
super(Profile, self).__init__(path, installer)
def __dump__(self, *args :str, **kwargs :str) -> Dict[str, str]:
diff --git a/archinstall/lib/storage.py b/archinstall/lib/storage.py
index aa4a3667..650b9c0e 100644
--- a/archinstall/lib/storage.py
+++ b/archinstall/lib/storage.py
@@ -7,7 +7,9 @@ import os
# (4. Added the ~/.config directory as an additional option for future reasons)
#
# And Keeping this in dict ensures that variables are shared across imports.
-storage = {
+from typing import Any, Dict
+
+storage: Dict[str, Any] = {
'PROFILE_PATH': [
'./profiles',
'~/.config/archinstall/profiles',
diff --git a/archinstall/lib/translation.py b/archinstall/lib/translation.py
index 767d6d36..74ffd691 100644
--- a/archinstall/lib/translation.py
+++ b/archinstall/lib/translation.py
@@ -5,9 +5,12 @@ import os
import gettext
from pathlib import Path
-from typing import List, Dict
+from typing import List, Dict, Any, TYPE_CHECKING
from .exceptions import TranslationError
+if TYPE_CHECKING:
+ _: Any
+
class Languages:
def __init__(self):
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index e57fca8a..7524dd8b 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -17,6 +17,7 @@ from .menu.text_input import TextInput
if TYPE_CHECKING:
from .disk.partition import Partition
+ _: Any
from .disk import BlockDevice, suggest_single_disk_layout, suggest_multi_disk_layout, valid_parted_position, all_blockdevices
from .exceptions import RequirementError, DiskError
@@ -36,6 +37,10 @@ from .disk.validators import fs_types
from .packages.packages import validate_package_list
+# used for signal handler
+SIG_TRIGGER = None
+
+
# TODO: These can be removed after the move to simple_menu.py
def get_terminal_height() -> int:
return shutil.get_terminal_size().lines