diff --git a/pmb/build/_package.py b/pmb/build/_package.py index a2367fde..4b487166 100644 --- a/pmb/build/_package.py +++ b/pmb/build/_package.py @@ -1,7 +1,8 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later import datetime -from typing import Any, Callable, Optional, TypedDict +from typing import Any, TypedDict +from collections.abc import Callable from pmb.build.other import BuildStatus from pmb.core.arch import Arch from pmb.core.context import Context @@ -215,7 +216,7 @@ def process_package( context: Context, queue_build: Callable, pkgname: str, - arch: Optional[Arch], + arch: Arch | None, fallback_arch: Arch, force: bool, ) -> list[str]: @@ -321,12 +322,12 @@ def process_package( def packages( context: Context, pkgnames: list[str], - arch: Optional[Arch] = None, + arch: Arch | None = None, force=False, strict=False, src=None, bootstrap_stage=BootstrapStage.NONE, - log_callback: Optional[Callable] = None, + log_callback: Callable | None = None, ) -> list[str]: """ Build a package and its dependencies with Alpine Linux' abuild. diff --git a/pmb/build/autodetect.py b/pmb/build/autodetect.py index ecca044d..59b1af08 100644 --- a/pmb/build/autodetect.py +++ b/pmb/build/autodetect.py @@ -3,7 +3,7 @@ from pathlib import Path from pmb.core.arch import Arch from pmb.helpers import logging -from typing import Any, Optional, Union +from typing import Any import pmb.config import pmb.chroot.apk @@ -15,7 +15,7 @@ from pmb.types import CrossCompileType # FIXME (#2324): type hint Arch -def arch_from_deviceinfo(pkgname, aport: Path) -> Optional[Arch]: +def arch_from_deviceinfo(pkgname, aport: Path) -> Arch | None: """ The device- packages are noarch packages. But it only makes sense to build them for the device's architecture, which is specified in the deviceinfo @@ -39,7 +39,7 @@ def arch_from_deviceinfo(pkgname, aport: Path) -> Optional[Arch]: @Cache("package") -def arch(package: Union[str, dict[str, Any]]): +def arch(package: str | dict[str, Any]): """ Find a good default in case the user did not specify for which architecture a package should be built. diff --git a/pmb/commands/repo_bootstrap.py b/pmb/commands/repo_bootstrap.py index f23a400c..1101567a 100644 --- a/pmb/commands/repo_bootstrap.py +++ b/pmb/commands/repo_bootstrap.py @@ -1,6 +1,5 @@ # Copyright 2024 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later -from typing import Optional from pmb.core.arch import Arch from pmb.core.chroot import Chroot, ChrootType from pmb.core.context import Context @@ -43,7 +42,7 @@ class RepoBootstrap(commands.Command): f"Couldn't find section 'repo:{self.repo}' in pmaports.cfg of" " current branch" ) - def __init__(self, arch: Optional[Arch], repository: str): + def __init__(self, arch: Arch | None, repository: str): context = get_context() if arch: self.arch = arch diff --git a/pmb/config/init.py b/pmb/config/init.py index dc698026..15fa5812 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -10,7 +10,7 @@ import glob import json import os import shutil -from typing import Any, Optional +from typing import Any import pmb.aportgen import pmb.config @@ -600,7 +600,7 @@ def ask_for_mirror(): return mirror -def ask_for_hostname(default: Optional[str], device): +def ask_for_hostname(default: str | None, device): while True: ret = pmb.helpers.cli.ask( "Device hostname (short form, e.g. 'foo')", None, (default or device), True diff --git a/pmb/config/pmaports.py b/pmb/config/pmaports.py index 92c79080..e56dc3fe 100644 --- a/pmb/config/pmaports.py +++ b/pmb/config/pmaports.py @@ -2,7 +2,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later import configparser from pathlib import Path -from typing import Optional from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_paths, pkgrepo_relative_path from pmb.helpers import logging import os @@ -89,7 +88,7 @@ def read_config_repos(): @Cache("aports") -def read_config(aports: Optional[Path] = None): +def read_config(aports: Path | None = None): """Read and verify pmaports.cfg. If aports is not specified and systemd is enabled, the returned channel will be the systemd one (e.g. systemd-edge instead of edge) diff --git a/pmb/config/sudo.py b/pmb/config/sudo.py index 730ea278..e01b5908 100644 --- a/pmb/config/sudo.py +++ b/pmb/config/sudo.py @@ -3,11 +3,10 @@ import os import shutil from functools import lru_cache -from typing import Optional @lru_cache -def which_sudo() -> Optional[str]: +def which_sudo() -> str | None: """Return a command required to run commands as root, if any. Find whether sudo or doas is installed for commands that require root. diff --git a/pmb/config/workdir.py b/pmb/config/workdir.py index 88b79be2..1d8f17de 100644 --- a/pmb/config/workdir.py +++ b/pmb/config/workdir.py @@ -8,7 +8,7 @@ dir.""" import configparser import os import time -from typing import Optional, overload +from typing import overload import pmb.config import pmb.config.pmaports @@ -48,7 +48,7 @@ def chroots_outdated() -> list[Chroot]: ... def chroots_outdated(chroot: Chroot) -> bool: ... -def chroots_outdated(chroot: Optional[Chroot] = None): +def chroots_outdated(chroot: Chroot | None = None): """Check if init dates from workdir.cfg indicate that any chroot is outdated. diff --git a/pmb/core/pkgrepo.py b/pmb/core/pkgrepo.py index f3d78a18..a1af27aa 100644 --- a/pmb/core/pkgrepo.py +++ b/pmb/core/pkgrepo.py @@ -1,7 +1,6 @@ import os import glob from pathlib import Path -from typing import Optional from collections.abc import Generator import pmb.config @@ -61,7 +60,7 @@ def pkgrepo_name_from_subdir(subdir: Path) -> str: raise RuntimeError(f"aports subdir '{subdir}' not found") -def pkgrepo_glob_one(path: str) -> Optional[Path]: +def pkgrepo_glob_one(path: str) -> Path | None: """ Search for the file denoted by path in all aports repositories. path can be a glob. diff --git a/pmb/flasher/variables.py b/pmb/flasher/variables.py index 3d8831ee..2d08934d 100644 --- a/pmb/flasher/variables.py +++ b/pmb/flasher/variables.py @@ -1,6 +1,5 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later -from typing import Optional import pmb.config.pmaports from pmb.core.chroot import Chroot from pmb.core.context import get_context @@ -20,8 +19,8 @@ def variables(args: PmbArgs, flavor: str, method: str): # updated and minimum pmbootstrap version bumped. # See also https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2243 - _partition_kernel: Optional[str] - _partition_rootfs: Optional[str] + _partition_kernel: str | None + _partition_rootfs: str | None if method.startswith("fastboot"): _partition_kernel = deviceinfo.flash_fastboot_partition_kernel or "boot" diff --git a/pmb/helpers/apk.py b/pmb/helpers/apk.py index 758b018d..2908ee6d 100644 --- a/pmb/helpers/apk.py +++ b/pmb/helpers/apk.py @@ -3,7 +3,6 @@ import os from collections.abc import Sequence from pathlib import Path -from typing import Optional import pmb.chroot import pmb.config.pmaports @@ -17,7 +16,7 @@ import pmb.parse.version from pmb.core.context import get_context -def _run(command, chroot: Optional[Chroot], output="log"): +def _run(command, chroot: Chroot | None, output="log"): """Run a command. :param command: command in list form @@ -33,7 +32,7 @@ def _run(command, chroot: Optional[Chroot], output="log"): return pmb.helpers.run.root(command, output=output) -def _prepare_fifo(chroot: Optional[Chroot]): +def _prepare_fifo(chroot: Chroot | None): """Prepare the progress fifo for reading / writing. :param chroot: whether to run the command inside the chroot or on the host @@ -87,7 +86,7 @@ def _compute_progress(line): return cur / tot if tot > 0 else 0 -def apk_with_progress(command: Sequence[PathString], chroot: Optional[Chroot] = None): +def apk_with_progress(command: Sequence[PathString], chroot: Chroot | None = None): """Run an apk subcommand while printing a progress bar to STDOUT. :param command: apk subcommand in list form diff --git a/pmb/helpers/aportupgrade.py b/pmb/helpers/aportupgrade.py index 9e62aa12..52d160a1 100644 --- a/pmb/helpers/aportupgrade.py +++ b/pmb/helpers/aportupgrade.py @@ -6,7 +6,6 @@ from pmb.helpers import logging import os import re import urllib.parse -from typing import Optional from pmb.types import PmbArgs import pmb.helpers.file @@ -48,7 +47,7 @@ def init_req_headers() -> None: ) -def get_package_version_info_github(repo_name: str, ref: Optional[str]): +def get_package_version_info_github(repo_name: str, ref: str | None): logging.debug(f"Trying GitHub repository: {repo_name}") # Get the URL argument to request a special ref, if needed @@ -70,7 +69,7 @@ def get_package_version_info_github(repo_name: str, ref: Optional[str]): } -def get_package_version_info_gitlab(gitlab_host: str, repo_name: str, ref: Optional[str]): +def get_package_version_info_gitlab(gitlab_host: str, repo_name: str, ref: str | None): logging.debug(f"Trying GitLab repository: {repo_name}") repo_name_safe = urllib.parse.quote(repo_name, safe="") diff --git a/pmb/helpers/devices.py b/pmb/helpers/devices.py index bda070be..e62a6647 100644 --- a/pmb/helpers/devices.py +++ b/pmb/helpers/devices.py @@ -2,11 +2,10 @@ # SPDX-License-Identifier: GPL-3.0-or-later import os from pathlib import Path -from typing import Optional from pmb.core.pkgrepo import pkgrepo_glob_one, pkgrepo_iglob -def find_path(codename: str, file="") -> Optional[Path]: +def find_path(codename: str, file="") -> Path | None: """Find path to device APKBUILD under `device/*/device-`. :param codename: device codename diff --git a/pmb/helpers/pmaports.py b/pmb/helpers/pmaports.py index d8519731..969ba138 100644 --- a/pmb/helpers/pmaports.py +++ b/pmb/helpers/pmaports.py @@ -12,7 +12,7 @@ from pmb.core.arch import Arch from pmb.core.pkgrepo import pkgrepo_iter_package_dirs from pmb.helpers import logging from pathlib import Path -from typing import Any, Optional +from typing import Any from collections.abc import Sequence from pmb.meta import Cache @@ -51,7 +51,7 @@ def get_list() -> Sequence[str]: return list(_find_apkbuilds().keys()) -def guess_main_dev(subpkgname) -> Optional[Path]: +def guess_main_dev(subpkgname) -> Path | None: """Check if a package without "-dev" at the end exists in pmaports or not, and log the appropriate message. Don't call this function directly, use guess_main() instead. @@ -77,7 +77,7 @@ def guess_main_dev(subpkgname) -> Optional[Path]: return None -def guess_main(subpkgname) -> Optional[Path]: +def guess_main(subpkgname) -> Path | None: """Find the main package by assuming it is a prefix of the subpkgname. We do that, because in some APKBUILDs the subpkgname="" variable gets @@ -165,7 +165,7 @@ def find(package, must_exist=True, subpackages=True, skip_extra_repos=False): """ # Try to get a cached result first (we assume that the aports don't change # in one pmbootstrap call) - ret: Optional[Path] = None + ret: Path | None = None # Sanity check if "*" in package: raise RuntimeError("Invalid pkgname: " + package) @@ -205,7 +205,7 @@ def find(package, must_exist=True, subpackages=True, skip_extra_repos=False): return ret -def find_optional(package: str) -> Optional[Path]: +def find_optional(package: str) -> Path | None: try: return find(package) except RuntimeError: @@ -216,7 +216,7 @@ def find_optional(package: str) -> Optional[Path]: @Cache("pkgname", subpackages=True) def get_with_path( pkgname, must_exist=True, subpackages=True, skip_extra_repos=False -) -> tuple[Optional[Path], Optional[dict[str, Any]]]: +) -> tuple[Path | None, dict[str, Any] | None]: """Find and parse an APKBUILD file. Run 'pmbootstrap apkbuild_parse hello-world' for a full output example. @@ -272,7 +272,7 @@ def find_providers(provide): # FIXME (#2324): split into an _optional variant or drop must_exist -def get_repo(pkgname, must_exist=True) -> Optional[str]: +def get_repo(pkgname, must_exist=True) -> str | None: """Get the repository folder of an aport. :pkgname: package name @@ -280,7 +280,7 @@ def get_repo(pkgname, must_exist=True) -> Optional[str]: :returns: a string like "main", "device", "cross", ... or None when the aport could not be found """ - aport: Optional[Path] + aport: Path | None if must_exist: aport = find(pkgname) else: diff --git a/pmb/helpers/repo.py b/pmb/helpers/repo.py index 19868467..373e746d 100644 --- a/pmb/helpers/repo.py +++ b/pmb/helpers/repo.py @@ -15,7 +15,6 @@ from pmb.core.arch import Arch from pmb.core.pkgrepo import pkgrepo_names from pmb.helpers import logging from pathlib import Path -from typing import Optional import pmb.config.pmaports from pmb.meta import Cache @@ -104,7 +103,7 @@ def urls(user_repository=False, mirrors_exclude: list[str] = []): def apkindex_files( - arch: Optional[Arch] = None, user_repository=True, exclude_mirrors: list[str] = [] + arch: Arch | None = None, user_repository=True, exclude_mirrors: list[str] = [] ) -> list[Path]: """Get a list of outside paths to all resolved APKINDEX.tar.gz files for a specific arch. @@ -130,7 +129,7 @@ def apkindex_files( @Cache("arch", force=False) -def update(arch: Optional[Arch] = None, force=False, existing_only=False): +def update(arch: Arch | None = None, force=False, existing_only=False): """Download the APKINDEX files for all URLs depending on the architectures. :param arch: * one Alpine architecture name ("x86_64", "armhf", ...) @@ -206,7 +205,7 @@ def update(arch: Optional[Arch] = None, force=False, existing_only=False): return True -def alpine_apkindex_path(repo="main", arch: Optional[Arch] = None): +def alpine_apkindex_path(repo="main", arch: Arch | None = None): """Get the path to a specific Alpine APKINDEX file on disk and download it if necessary. :param repo: Alpine repository name (e.g. "main") diff --git a/pmb/helpers/run.py b/pmb/helpers/run.py index c7ee2dd9..527bb489 100644 --- a/pmb/helpers/run.py +++ b/pmb/helpers/run.py @@ -5,17 +5,16 @@ from pathlib import Path import subprocess from pmb.core.arch import Arch import pmb.helpers.run_core -from typing import Optional from collections.abc import Sequence from pmb.types import Env, PathString def user( cmd: Sequence[PathString], - working_dir: Optional[Path] = None, + working_dir: Path | None = None, output: str = "log", output_return: bool = False, - check: Optional[bool] = None, + check: bool | None = None, env: Env = {}, sudo: bool = False, ) -> str | int | subprocess.Popen: @@ -56,9 +55,9 @@ def user( # FIXME: should probably use some kind of wrapper class / builder pattern for all these parameters... def user_output( cmd: Sequence[PathString], - working_dir: Optional[Path] = None, + working_dir: Path | None = None, output: str = "log", - check: Optional[bool] = None, + check: bool | None = None, env: Env = {}, sudo: bool = False, ) -> str: diff --git a/pmb/helpers/run_core.py b/pmb/helpers/run_core.py index cb557aca..33cd5ded 100644 --- a/pmb/helpers/run_core.py +++ b/pmb/helpers/run_core.py @@ -13,7 +13,6 @@ import subprocess import sys import threading import time -from typing import Optional from collections.abc import Sequence import pmb.helpers.run @@ -23,7 +22,7 @@ import pmb.helpers.run def flat_cmd( - cmds: Sequence[Sequence[PathString]], working_dir: Optional[Path] = None, env: Env = {} + cmds: Sequence[Sequence[PathString]], working_dir: Path | None = None, env: Env = {} ): """Convert a shell command passed as list into a flat shell string with proper escaping. diff --git a/pmb/install/_install.py b/pmb/install/_install.py index 826a36cd..ecf25306 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -7,7 +7,6 @@ import re import glob import shlex import sys -from typing import Optional from collections.abc import Sequence from pathlib import Path @@ -388,7 +387,7 @@ def setup_timezone(chroot: Chroot, timezone: str): pmb.chroot.root(setup_tz_cmd, chroot) -def setup_hostname(device: str, hostname: Optional[str]): +def setup_hostname(device: str, hostname: str | None): """ Set the hostname and update localhost address in /etc/hosts """ @@ -840,7 +839,7 @@ def install_system_image( boot_label="pmOS_boot", root_label="pmOS_root", split=False, - disk: Optional[Path] = None, + disk: Path | None = None, ): """ :param size_reserve: empty partition between root and boot in MiB (pma#463) diff --git a/pmb/install/blockdevice.py b/pmb/install/blockdevice.py index 41a4132b..fedb371d 100644 --- a/pmb/install/blockdevice.py +++ b/pmb/install/blockdevice.py @@ -1,6 +1,5 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later -from typing import Optional from pmb.helpers import logging import os from pathlib import Path @@ -122,7 +121,7 @@ def create_and_mount_image(args: PmbArgs, size_boot, size_root, size_reserve, sp pmb.helpers.mount.bind_file(device, Chroot.native() / mount_point) -def create(args: PmbArgs, size_boot, size_root, size_reserve, split, disk: Optional[Path]): +def create(args: PmbArgs, size_boot, size_root, size_reserve, split, disk: Path | None): """ Create /dev/install (the "install blockdevice"). diff --git a/pmb/install/partition.py b/pmb/install/partition.py index 18b9c4b1..a4efb7aa 100644 --- a/pmb/install/partition.py +++ b/pmb/install/partition.py @@ -1,7 +1,6 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later from pathlib import Path -from typing import Optional from pmb.helpers import logging import os import time @@ -13,7 +12,7 @@ from pmb.core import Chroot # FIXME (#2324): this function drops disk to a string because it's easier # to manipulate, this is probably bad. -def partitions_mount(device: str, layout, disk: Optional[Path]): +def partitions_mount(device: str, layout, disk: Path | None): """ Mount blockdevices of partitions inside native chroot :param layout: partition layout from get_partition_layout() diff --git a/pmb/meta/__init__.py b/pmb/meta/__init__.py index 27d26728..64f1bddf 100644 --- a/pmb/meta/__init__.py +++ b/pmb/meta/__init__.py @@ -2,7 +2,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later import copy -from typing import Callable, Generic, Optional, TypeVar, overload +from typing import Generic, Optional, TypeVar, overload +from collections.abc import Callable import inspect @@ -78,7 +79,7 @@ class Cache: # Build the cache key, or return None to not cache in the case where # we only cache when an argument has a specific value - def build_key(self, func: Callable, *args, **kwargs) -> Optional[str]: + def build_key(self, func: Callable, *args, **kwargs) -> str | None: key = "~" # Easy case: cache irrelevant of arguments if not self.params and not self.kwargs: diff --git a/pmb/parse/apkindex.py b/pmb/parse/apkindex.py index 3d4518e6..09c01c06 100644 --- a/pmb/parse/apkindex.py +++ b/pmb/parse/apkindex.py @@ -1,7 +1,7 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later import collections -from typing import Any, Optional +from typing import Any from collections.abc import Sequence from pmb.core.arch import Arch from pmb.core.context import get_context @@ -284,7 +284,7 @@ def clear_cache(path: Path): return False -def providers(package, arch: Optional[Arch] = None, must_exist=True, indexes=None): +def providers(package, arch: Arch | None = None, must_exist=True, indexes=None): """ Get all packages, which provide one package. @@ -380,7 +380,7 @@ def provider_shortest(providers, pkgname): return providers[ret] -def package(package, arch: Optional[Arch] = None, must_exist=True, indexes=None): +def package(package, arch: Arch | None = None, must_exist=True, indexes=None): """ Get a specific package's data from an apkindex. diff --git a/pmb/parse/cpuinfo.py b/pmb/parse/cpuinfo.py index 35548369..fe3ffb3f 100644 --- a/pmb/parse/cpuinfo.py +++ b/pmb/parse/cpuinfo.py @@ -1,10 +1,9 @@ # Copyright 2023 Lary Gibaud # SPDX-License-Identifier: GPL-3.0-or-later import re -from typing import Optional -def arm_big_little_first_group_ncpus() -> Optional[int]: +def arm_big_little_first_group_ncpus() -> int | None: """ Infer from /proc/cpuinfo on aarch64 if this is a big/little architecture (if there is different processor models) and the number of cores in the diff --git a/pmb/parse/deviceinfo.py b/pmb/parse/deviceinfo.py index 06073231..dcc3641c 100644 --- a/pmb/parse/deviceinfo.py +++ b/pmb/parse/deviceinfo.py @@ -2,7 +2,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later import copy from pathlib import Path -from typing import Optional from pmb.core.context import get_context from pmb.core.arch import Arch from pmb.helpers import logging @@ -102,73 +101,73 @@ class Deviceinfo: # device chassis: str - keyboard: Optional[str] = "" - external_storage: Optional[str] = "" - gpu_accelerated: Optional[bool] = False - dev_touchscreen: Optional[str] = "" - dev_touchscreen_calibration: Optional[str] = "" - append_dtb: Optional[str] = "" + keyboard: str | None = "" + external_storage: str | None = "" + gpu_accelerated: bool | None = False + dev_touchscreen: str | None = "" + dev_touchscreen_calibration: str | None = "" + append_dtb: str | None = "" # bootloader flash_method: str = "" - boot_filesystem: Optional[str] = "" + boot_filesystem: str | None = "" # flash - flash_heimdall_partition_kernel: Optional[str] = "" - flash_heimdall_partition_initfs: Optional[str] = "" - flash_heimdall_partition_rootfs: Optional[str] = "" - flash_heimdall_partition_system: Optional[str] = "" # deprecated - flash_heimdall_partition_vbmeta: Optional[str] = "" - flash_heimdall_partition_dtbo: Optional[str] = "" - flash_fastboot_partition_kernel: Optional[str] = "" - flash_fastboot_partition_rootfs: Optional[str] = "" - flash_fastboot_partition_system: Optional[str] = "" # deprecated - flash_fastboot_partition_vbmeta: Optional[str] = "" - flash_fastboot_partition_dtbo: Optional[str] = "" - flash_rk_partition_kernel: Optional[str] = "" - flash_rk_partition_rootfs: Optional[str] = "" - flash_rk_partition_system: Optional[str] = "" # deprecated - flash_mtkclient_partition_kernel: Optional[str] = "" - flash_mtkclient_partition_rootfs: Optional[str] = "" - flash_mtkclient_partition_vbmeta: Optional[str] = "" - flash_mtkclient_partition_dtbo: Optional[str] = "" - generate_legacy_uboot_initfs: Optional[str] = "" - kernel_cmdline: Optional[str] = "" - generate_bootimg: Optional[str] = "" - header_version: Optional[str] = "" - bootimg_qcdt: Optional[str] = "" - bootimg_mtk_mkimage: Optional[str] = "" # deprecated - bootimg_mtk_label_kernel: Optional[str] = "" - bootimg_mtk_label_ramdisk: Optional[str] = "" - bootimg_dtb_second: Optional[str] = "" - bootimg_custom_args: Optional[str] = "" - flash_offset_base: Optional[str] = "" - flash_offset_dtb: Optional[str] = "" - flash_offset_kernel: Optional[str] = "" - flash_offset_ramdisk: Optional[str] = "" - flash_offset_second: Optional[str] = "" - flash_offset_tags: Optional[str] = "" - flash_pagesize: Optional[str] = "" - flash_fastboot_max_size: Optional[str] = "" - flash_sparse: Optional[str] = "" - flash_sparse_samsung_format: Optional[str] = "" - rootfs_image_sector_size: Optional[str] = "" - sd_embed_firmware: Optional[str] = "" - sd_embed_firmware_step_size: Optional[str] = "" - partition_blacklist: Optional[str] = "" - boot_part_start: Optional[str] = "" - partition_type: Optional[str] = "" - root_filesystem: Optional[str] = "" - flash_kernel_on_update: Optional[str] = "" - cgpt_kpart: Optional[str] = "" - cgpt_kpart_start: Optional[str] = "" - cgpt_kpart_size: Optional[str] = "" + flash_heimdall_partition_kernel: str | None = "" + flash_heimdall_partition_initfs: str | None = "" + flash_heimdall_partition_rootfs: str | None = "" + flash_heimdall_partition_system: str | None = "" # deprecated + flash_heimdall_partition_vbmeta: str | None = "" + flash_heimdall_partition_dtbo: str | None = "" + flash_fastboot_partition_kernel: str | None = "" + flash_fastboot_partition_rootfs: str | None = "" + flash_fastboot_partition_system: str | None = "" # deprecated + flash_fastboot_partition_vbmeta: str | None = "" + flash_fastboot_partition_dtbo: str | None = "" + flash_rk_partition_kernel: str | None = "" + flash_rk_partition_rootfs: str | None = "" + flash_rk_partition_system: str | None = "" # deprecated + flash_mtkclient_partition_kernel: str | None = "" + flash_mtkclient_partition_rootfs: str | None = "" + flash_mtkclient_partition_vbmeta: str | None = "" + flash_mtkclient_partition_dtbo: str | None = "" + generate_legacy_uboot_initfs: str | None = "" + kernel_cmdline: str | None = "" + generate_bootimg: str | None = "" + header_version: str | None = "" + bootimg_qcdt: str | None = "" + bootimg_mtk_mkimage: str | None = "" # deprecated + bootimg_mtk_label_kernel: str | None = "" + bootimg_mtk_label_ramdisk: str | None = "" + bootimg_dtb_second: str | None = "" + bootimg_custom_args: str | None = "" + flash_offset_base: str | None = "" + flash_offset_dtb: str | None = "" + flash_offset_kernel: str | None = "" + flash_offset_ramdisk: str | None = "" + flash_offset_second: str | None = "" + flash_offset_tags: str | None = "" + flash_pagesize: str | None = "" + flash_fastboot_max_size: str | None = "" + flash_sparse: str | None = "" + flash_sparse_samsung_format: str | None = "" + rootfs_image_sector_size: str | None = "" + sd_embed_firmware: str | None = "" + sd_embed_firmware_step_size: str | None = "" + partition_blacklist: str | None = "" + boot_part_start: str | None = "" + partition_type: str | None = "" + root_filesystem: str | None = "" + flash_kernel_on_update: str | None = "" + cgpt_kpart: str | None = "" + cgpt_kpart_start: str | None = "" + cgpt_kpart_size: str | None = "" # weston - weston_pixman_type: Optional[str] = "" + weston_pixman_type: str | None = "" # keymaps - keymaps: Optional[str] = "" + keymaps: str | None = "" @staticmethod def __validate(info: dict[str, str], path: Path): @@ -250,7 +249,7 @@ class Deviceinfo: f" and try again: {path}" ) - def __init__(self, path: Path, kernel: Optional[str] = None): + def __init__(self, path: Path, kernel: str | None = None): ret = {} with open(path) as handle: for line in handle: diff --git a/pmb/sideload/__init__.py b/pmb/sideload/__init__.py index b98a7b12..f0ccf7b4 100644 --- a/pmb/sideload/__init__.py +++ b/pmb/sideload/__init__.py @@ -97,7 +97,7 @@ def ssh_install_apks(args: PmbArgs, user, host, port, paths): def sideload( - args: PmbArgs, user: str, host: str, port: str, arch: Optional[Arch], copy_key: bool, pkgnames + args: PmbArgs, user: str, host: str, port: str, arch: Arch | None, copy_key: bool, pkgnames ): """Build packages if necessary and install them via SSH. diff --git a/pmb/types.py b/pmb/types.py index e556470d..a8263f8d 100644 --- a/pmb/types.py +++ b/pmb/types.py @@ -7,7 +7,7 @@ from typing import Literal, Optional, TypedDict, Union from pmb.core.arch import Arch -CrossCompileType = Optional[Union[Literal["native"], Literal["crossdirect"]]] +CrossCompileType = Optional[Literal["native"] | Literal["crossdirect"]] PathString = Union[Path, str] Env = dict[str, PathString] @@ -17,9 +17,9 @@ Env = dict[str, PathString] class PartitionLayout(TypedDict): - kernel: Optional[int] + kernel: int | None boot: int - reserve: Optional[int] + reserve: int | None root: int @@ -42,8 +42,8 @@ class PmbArgs(Namespace): all_stable: bool android_recovery_zip: bool apkindex_path: Path - aports: Optional[list[Path]] - arch: Optional[Arch] + aports: list[Path] | None + arch: Arch | None as_root: bool assume_yes: bool auto: bool