Fix (some) mypy things (#996)
* Fix mypy things * Fix flake8 Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
This commit is contained in:
parent
0fed839110
commit
fa87d85708
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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]:
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue