treewide: type hint args (MR 2252)

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-05-22 22:30:33 +02:00 committed by Oliver Smith
parent 198f302a36
commit 7b14ef597b
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
40 changed files with 152 additions and 151 deletions

View file

@ -12,7 +12,7 @@ import pmb.helpers.pmaports
from pmb.core import Chroot
def update(args, pkgname):
def update(args: PmbArgs, pkgname):
"""Fetch all sources and update the checksums in the APKBUILD."""
pmb.build.init_abuild_minimal(args)
pmb.build.copy_to_buildpath(args, pkgname)
@ -26,7 +26,7 @@ def update(args, pkgname):
pmb.helpers.run.user(args, ["cp", source, target])
def verify(args, pkgname):
def verify(args: PmbArgs, pkgname):
"""Fetch all sources and verify their checksums."""
pmb.build.init_abuild_minimal(args)
pmb.build.copy_to_buildpath(args, pkgname)

View file

@ -89,7 +89,7 @@ def find_kbuild_output_dir(function_body):
"can't resolve it, please open an issue.")
def modify_apkbuild(args, pkgname, aport):
def modify_apkbuild(args: PmbArgs, pkgname, aport):
"""Modify kernel APKBUILD to package build output from envkernel.sh."""
apkbuild_path = aport + "/APKBUILD"
apkbuild = pmb.parse.apkbuild(apkbuild_path)

View file

@ -97,7 +97,7 @@ def ask(question="Continue?", choices=["y", "n"], default="n",
validation_regex + "). Please try again.")
def confirm(args, question="Continue?", default=False, no_assumptions=False):
def confirm(args: PmbArgs, question="Continue?", default=False, no_assumptions=False):
"""Convenience wrapper around ask for simple yes-no questions with validation.
:param no_assumptions: ask for confirmation, even if "pmbootstrap -y' is set
@ -111,7 +111,7 @@ def confirm(args, question="Continue?", default=False, no_assumptions=False):
return answer == "y"
def progress_print(args, progress):
def progress_print(args: PmbArgs, progress):
"""Print a snapshot of a progress bar to STDOUT.
Call progress_flush to end printing progress and clear the line. No output is printed in

View file

@ -20,7 +20,7 @@ def replace(path, old, new):
handle.write(text)
def replace_apkbuild(args, pkgname, key, new, in_quotes=False):
def replace_apkbuild(args: PmbArgs, pkgname, key, new, in_quotes=False):
"""Replace one key=value line in an APKBUILD and verify it afterwards.
:param pkgname: package name, e.g. "hello-world"

View file

@ -13,7 +13,7 @@ import pmb.helpers.pmaports
import pmb.helpers.run
def get_path(args, name_repo):
def get_path(args: PmbArgs, name_repo):
"""Get the path to the repository.
The path is either the default one in the work dir, or a user-specified one in args.
@ -25,7 +25,7 @@ def get_path(args, name_repo):
return pmb.config.work / "cache_git/" + name_repo
def clone(args, name_repo):
def clone(args: PmbArgs, name_repo):
"""Clone a git repository to $WORK/cache_git/$name_repo.
(or to the overridden path set in args, as with ``pmbootstrap --aports``).
@ -56,7 +56,7 @@ def clone(args, name_repo):
open(fetch_head, "w").close()
def rev_parse(args, path, revision="HEAD", extra_args: list = []):
def rev_parse(args: PmbArgs, path, revision="HEAD", extra_args: list = []):
"""Run "git rev-parse" in a specific repository dir.
:param path: to the git repository
@ -81,13 +81,13 @@ def can_fast_forward(args: PmbArgs, path, branch_upstream, branch="HEAD"):
raise RuntimeError("Unexpected exit code from git: " + str(ret))
def clean_worktree(args, path):
def clean_worktree(args: PmbArgs, path):
"""Check if there are not any modified files in the git dir."""
command = ["git", "status", "--porcelain"]
return pmb.helpers.run.user(args, command, path, output_return=True) == ""
def get_upstream_remote(args, name_repo):
def get_upstream_remote(args: PmbArgs, name_repo):
"""Find the remote, which matches the git URL from the config.
Usually "origin", but the user may have set up their git repository differently.
@ -159,7 +159,7 @@ def parse_channels_cfg(args):
return ret
def get_branches_official(args, name_repo):
def get_branches_official(args: PmbArgs, name_repo):
"""Get all branches that point to official release channels.
:returns: list of supported branches, e.g. ["master", "3.11"]
@ -177,7 +177,7 @@ def get_branches_official(args, name_repo):
return ret
def pull(args, name_repo):
def pull(args: PmbArgs, name_repo):
"""Check if on official branch and essentially try ``git pull --ff-only``.
Instead of really doing ``git pull --ff-only``, do it in multiple steps
@ -251,7 +251,7 @@ def get_topdir(args: PmbArgs, path: Path):
path, output_return=True, check=False).rstrip()
def get_files(args, path):
def get_files(args: PmbArgs, path):
"""Get all files inside a git repository, that are either already in the git tree or are not in gitignore.
Do not list deleted files. To be used for creating a tarball of the git repository.

View file

@ -11,7 +11,7 @@ import pmb.helpers.run
import pmb.helpers.pmaports
def check(args, pkgnames):
def check(args: PmbArgs, pkgnames):
"""Run apkbuild-lint on the supplied packages.
:param pkgnames: Names of the packages to lint

View file

@ -24,7 +24,7 @@ def remove_operators(package):
return package
def get(args, pkgname, arch, replace_subpkgnames=False, must_exist=True):
def get(args: PmbArgs, pkgname, arch, replace_subpkgnames=False, must_exist=True):
"""Find a package in pmaports, and as fallback in the APKINDEXes of the binary packages.
:param pkgname: package name (e.g. "hello-world")
@ -130,7 +130,7 @@ def get(args, pkgname, arch, replace_subpkgnames=False, must_exist=True):
" could not find this package in any APKINDEX!")
def depends_recurse(args, pkgname, arch):
def depends_recurse(args: PmbArgs, pkgname, arch):
"""Recursively resolve all of the package's dependencies.
:param pkgname: name of the package (e.g. "device-samsung-i9100")
@ -169,7 +169,7 @@ def depends_recurse(args, pkgname, arch):
return ret
def check_arch(args, pkgname, arch, binary=True):
def check_arch(args: PmbArgs, pkgname, arch, binary=True):
"""Check if a package be built for a certain architecture, or is there a binary package for it.
:param pkgname: name of the package

View file

@ -10,7 +10,7 @@ import pmb.parse
import pmb.parse.apkindex
def package(args, pkgname, reason="", dry=False):
def package(args: PmbArgs, pkgname, reason="", dry=False):
"""Increase the pkgrel in the APKBUILD of a specific package.
:param pkgname: name of the package
@ -44,7 +44,7 @@ def package(args, pkgname, reason="", dry=False):
path)
def auto_apkindex_package(args, arch, aport, apk, dry=False):
def auto_apkindex_package(args: PmbArgs, arch, aport, apk, dry=False):
"""Bump the pkgrel of a specific package if it is outdated in the given APKINDEX.
:param arch: the architecture, e.g. "armhf"
@ -101,7 +101,7 @@ def auto_apkindex_package(args, arch, aport, apk, dry=False):
return True
def auto(args, dry=False):
def auto(args: PmbArgs, dry=False):
""":returns: list of aport names, where the pkgrel needed to be changed"""
ret = []
for arch in pmb.config.build_device_architectures:

View file

@ -44,7 +44,7 @@ def get_list(args: PmbArgs) -> Sequence[str]:
return list(_find_apkbuilds(args).keys())
def guess_main_dev(args, subpkgname):
def guess_main_dev(args: PmbArgs, subpkgname):
"""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.
@ -227,7 +227,7 @@ def get(args: PmbArgs, pkgname, must_exist=True, subpackages=True):
return None
def find_providers(args, provide):
def find_providers(args: PmbArgs, provide):
"""Search for providers of the specified (virtual) package in pmaports.
Note: Currently only providers from a single APKBUILD are returned.
@ -251,7 +251,7 @@ def find_providers(args, provide):
key=lambda p: p[1].get('provider_priority', 0))
def get_repo(args, pkgname, must_exist=True):
def get_repo(args: PmbArgs, pkgname, must_exist=True):
"""Get the repository folder of an aport.
:pkgname: package name

View file

@ -46,7 +46,7 @@ def hash(url, length=8):
return ret
def urls(args, user_repository=True, postmarketos_mirror=True, alpine=True):
def urls(args: PmbArgs, user_repository=True, postmarketos_mirror=True, alpine=True):
"""Get a list of repository URLs, as they are in /etc/apk/repositories.
:param user_repository: add /mnt/pmbootstrap/packages
@ -117,7 +117,7 @@ def apkindex_files(args: PmbArgs, arch=None, user_repository=True, pmos=True,
return ret
def update(args, arch=None, force=False, existing_only=False):
def update(args: PmbArgs, arch=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", ...)
@ -199,7 +199,7 @@ def update(args, arch=None, force=False, existing_only=False):
return True
def alpine_apkindex_path(args, repo="main", arch=None):
def alpine_apkindex_path(args: PmbArgs, repo="main", arch=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")

View file

@ -8,7 +8,7 @@ import pmb.helpers.package
import pmb.helpers.pmaports
def filter_missing_packages(args, arch, pkgnames):
def filter_missing_packages(args: PmbArgs, arch, pkgnames):
"""Create a subset of pkgnames with missing or outdated binary packages.
:param arch: architecture (e.g. "armhf")
@ -25,7 +25,7 @@ def filter_missing_packages(args, arch, pkgnames):
return ret
def filter_aport_packages(args, arch, pkgnames):
def filter_aport_packages(args: PmbArgs, arch, pkgnames):
"""Create a subset of pkgnames where each one has an aport.
:param arch: architecture (e.g. "armhf")
@ -39,7 +39,7 @@ def filter_aport_packages(args, arch, pkgnames):
return ret
def filter_arch_packages(args, arch, pkgnames):
def filter_arch_packages(args: PmbArgs, arch, pkgnames):
"""Create a subset of pkgnames with packages removed that can not be built for a certain arch.
:param arch: architecture (e.g. "armhf")
@ -53,7 +53,7 @@ def filter_arch_packages(args, arch, pkgnames):
return ret
def get_relevant_packages(args, arch, pkgname=None, built=False):
def get_relevant_packages(args: PmbArgs, arch, pkgname=None, built=False):
"""Get all packages that can be built for the architecture in question.
:param arch: architecture (e.g. "armhf")
@ -87,7 +87,7 @@ def get_relevant_packages(args, arch, pkgname=None, built=False):
return ret
def generate_output_format(args, arch, pkgnames):
def generate_output_format(args: PmbArgs, arch, pkgnames):
"""Generate the detailed output format.
:param arch: architecture
@ -113,7 +113,7 @@ def generate_output_format(args, arch, pkgnames):
return ret
def generate(args, arch, overview, pkgname=None, built=False):
def generate(args: PmbArgs, arch, overview, pkgname=None, built=False):
"""Get packages that need to be built, with all their dependencies.
:param arch: architecture (e.g. "armhf")

View file

@ -115,7 +115,7 @@ def pipe_read(process, output_to_stdout=False, output_return=False,
return
def kill_process_tree(args, pid, ppids, sudo):
def kill_process_tree(args: PmbArgs, pid, ppids, sudo):
"""Recursively kill a pid and its child processes.
:param pid: process id that will be killed
@ -134,7 +134,7 @@ def kill_process_tree(args, pid, ppids, sudo):
kill_process_tree(args, child_pid, ppids, sudo)
def kill_command(args, pid, sudo):
def kill_command(args: PmbArgs, pid, sudo):
"""Kill a command process and recursively kill its child processes.
:param pid: process id that will be killed
@ -230,7 +230,7 @@ def foreground_tui(cmd, working_dir=None):
return process.wait()
def check_return_code(args, code, log_message):
def check_return_code(args: PmbArgs, code, log_message):
"""Check the return code of a command.
:param code: exit code to check

View file

@ -7,7 +7,7 @@ import pmb.helpers.pmaports
import pmb.parse
def list(args, arch):
def list(args: PmbArgs, arch):
"""Get all UIs, for which aports are available with their description.
:param arch: device architecture, for which the UIs must be available

View file

@ -52,7 +52,7 @@ def ssh_find_arch(args: PmbArgs, user: str, host: str, port: str) -> str:
return alpine_architecture
def ssh_install_apks(args, user, host, port, paths):
def ssh_install_apks(args: PmbArgs, user, host, port, paths):
""" Copy binary packages via SCP and install them via SSH.
:param user: target device ssh username
:param host: target device ssh hostname

View file

@ -6,9 +6,10 @@ import os
import pmb.helpers.git
import pmb.helpers.run
import shutil
from pmb.core.types import PmbArgs
def prepare_tmpdir(args, monkeypatch, tmpdir):
def prepare_tmpdir(args: PmbArgs, monkeypatch, tmpdir):
""" Prepare git repositories in tmpdir, and override related functions.
Git repositories:
@ -50,16 +51,16 @@ def prepare_tmpdir(args, monkeypatch, tmpdir):
run_git(["checkout", "-b", "master", "--track", "origin2/master"])
# Override get_path()
def get_path(args, name_repo):
def get_path(args: PmbArgs, name_repo):
return path_local
monkeypatch.setattr(pmb.helpers.git, "get_path", get_path)
# Override get_upstream_remote()
def get_u_r(args, name_repo):
def get_u_r(args: PmbArgs, name_repo):
return "origin"
monkeypatch.setattr(pmb.helpers.git, "get_upstream_remote", get_u_r)
return path_local, run_git
def copy_dotgit(args, tmpdir):
def copy_dotgit(args: PmbArgs, tmpdir):
shutil.copytree(args.aports + "/.git", tmpdir + "/.git", ignore_dangling_symlinks=True)

View file

@ -25,11 +25,11 @@ def test_install_build(monkeypatch, args):
func = pmb.chroot.apk.install_build
ret_apkindex_package = None
def fake_build_package(args, package, arch):
def fake_build_package(args: PmbArgs, package, arch):
return "build-pkg"
monkeypatch.setattr(pmb.build, "package", fake_build_package)
def fake_apkindex_package(args, package, arch, must_exist):
def fake_apkindex_package(args: PmbArgs, package, arch, must_exist):
return ret_apkindex_package
monkeypatch.setattr(pmb.parse.apkindex, "package", fake_apkindex_package)
@ -91,12 +91,12 @@ def test_install_run_apk(monkeypatch, args):
func = pmb.chroot.apk.install_run_apk
suffix = Suffix.native()
def fake_chroot_root(args, command, suffix):
def fake_chroot_root(args: PmbArgs, command, suffix):
global cmds
cmds += [command]
monkeypatch.setattr(pmb.chroot, "root", fake_chroot_root)
def fake_apk_progress(args, command, chroot, suffix):
def fake_apk_progress(args: PmbArgs, command, chroot, suffix):
global cmds_progress
cmds_progress += [command]
monkeypatch.setattr(pmb.helpers.apk, "apk_with_progress", fake_apk_progress)

View file

@ -73,7 +73,7 @@ def test_read_signature_info(args):
pmb.chroot.user(args, ["rm", "-r", tmp_path])
def test_successful_extraction(args, tmpdir):
def test_successful_extraction(args: PmbArgs, tmpdir):
if os.path.exists(args.work + "/apk.static"):
os.remove(args.work + "/apk.static")
@ -82,7 +82,7 @@ def test_successful_extraction(args, tmpdir):
os.remove(args.work + "/apk.static")
def test_signature_verification(args, tmpdir):
def test_signature_verification(args: PmbArgs, tmpdir):
if os.path.exists(args.work + "/apk.static"):
os.remove(args.work + "/apk.static")
@ -116,7 +116,7 @@ def test_signature_verification(args, tmpdir):
assert "downgrade attack" in str(e.value)
def test_outdated_version(args, monkeypatch):
def test_outdated_version(args: PmbArgs, monkeypatch):
if os.path.exists(args.work + "/apk.static"):
os.remove(args.work + "/apk.static")

View file

@ -28,7 +28,7 @@ def args(tmpdir, request):
return args
def test_aportgen_compare_output(args, tmpdir, monkeypatch):
def test_aportgen_compare_output(args: PmbArgs, tmpdir, monkeypatch):
# Fake aports folder in tmpdir
tmpdir = str(tmpdir)
pmb_test.git.copy_dotgit(args, tmpdir)
@ -37,7 +37,7 @@ def test_aportgen_compare_output(args, tmpdir, monkeypatch):
testdata = pmb_test.const.testdata + "/aportgen"
# Override get_upstream_aport() to point to testdata
def func(args, upstream_path, arch=None):
def func(args: PmbArgs, upstream_path, arch=None):
return testdata + "/aports/main/" + upstream_path
monkeypatch.setattr(pmb.aportgen.core, "get_upstream_aport", func)
@ -51,7 +51,7 @@ def test_aportgen_compare_output(args, tmpdir, monkeypatch):
assert filecmp.cmp(path_new, path_old, False)
def test_aportgen_fork_alpine_compare_output(args, tmpdir, monkeypatch):
def test_aportgen_fork_alpine_compare_output(args: PmbArgs, tmpdir, monkeypatch):
# Fake aports folder in tmpdir
tmpdir = str(tmpdir)
pmb_test.git.copy_dotgit(args, tmpdir)
@ -61,7 +61,7 @@ def test_aportgen_fork_alpine_compare_output(args, tmpdir, monkeypatch):
args.fork_alpine = True
# Override get_upstream_aport() to point to testdata
def func(args, upstream_path, arch=None):
def func(args: PmbArgs, upstream_path, arch=None):
return testdata + "/aports/main/" + upstream_path
monkeypatch.setattr(pmb.aportgen.core, "get_upstream_aport", func)
@ -74,7 +74,7 @@ def test_aportgen_fork_alpine_compare_output(args, tmpdir, monkeypatch):
assert filecmp.cmp(path_new, path_old, False)
def test_aportgen(args, tmpdir):
def test_aportgen(args: PmbArgs, tmpdir):
# Fake aports folder in tmpdir
testdata = pmb_test.const.testdata
tmpdir = str(tmpdir)
@ -101,7 +101,7 @@ def test_aportgen_invalid_generator(args):
assert "No generator available" in str(e.value)
def test_aportgen_get_upstream_aport(args, monkeypatch):
def test_aportgen_get_upstream_aport(args: PmbArgs, monkeypatch):
# Fake pmb.parse.apkbuild()
def fake_apkbuild(*args, **kwargs):
return apkbuild

View file

@ -46,7 +46,7 @@ def args(tmpdir, request):
return args
def generate(args, monkeypatch, answers):
def generate(args: PmbArgs, monkeypatch, answers):
"""
Generate the device-new-device and linux-new-device aports (with a patched
pmb.helpers.cli()).
@ -91,7 +91,7 @@ def generate(args, monkeypatch, answers):
return (deviceinfo, apkbuild, apkbuild_linux)
def remove_contributor_maintainer_lines(args, path):
def remove_contributor_maintainer_lines(args: PmbArgs, path):
with open(path, "r+", encoding="utf-8") as handle:
lines_new = []
for line in handle.readlines():
@ -106,7 +106,7 @@ def remove_contributor_maintainer_lines(args, path):
handle.truncate()
def test_aportgen_device_wizard(args, monkeypatch):
def test_aportgen_device_wizard(args: PmbArgs, monkeypatch):
"""
Generate a device-testsuite-testdevice and linux-testsuite-testdevice
package multiple times and check if the output is correct. Also build the

View file

@ -85,7 +85,7 @@ def test_check_build_for_arch(monkeypatch, args):
# Fake APKBUILD data
apkbuild = {"pkgname": "testpkgname"}
def fake_helpers_pmaports_get(args, pkgname):
def fake_helpers_pmaports_get(args: PmbArgs, pkgname):
return apkbuild
monkeypatch.setattr(pmb.helpers.pmaports, "get", fake_helpers_pmaports_get)
@ -138,7 +138,7 @@ def test_get_depends(monkeypatch):
assert func(args, apkbuild) == ["a", "b", "c", "e"]
def test_build_depends(args, monkeypatch):
def test_build_depends(args: PmbArgs, monkeypatch):
# Shortcut and fake apkbuild
func = pmb.build._package.build_depends
apkbuild = {"pkgname": "test", "depends": ["a", "!c"],
@ -155,7 +155,7 @@ def test_build_depends(args, monkeypatch):
["a", "b"])
def test_build_depends_no_binary_error(args, monkeypatch):
def test_build_depends_no_binary_error(args: PmbArgs, monkeypatch):
# Shortcut and fake apkbuild
func = pmb.build._package.build_depends
apkbuild = {"pkgname": "test", "depends": ["some-invalid-package-here"],
@ -175,14 +175,14 @@ def test_build_depends_no_binary_error(args, monkeypatch):
assert func(args, apkbuild, "armhf", True) == (["alpine-base"], [])
def test_build_depends_binary_outdated(args, monkeypatch):
def test_build_depends_binary_outdated(args: PmbArgs, monkeypatch):
""" pmbootstrap runs with --no-depends and dependency binary package is
outdated (#1895) """
# Override pmb.parse.apkindex.package(): pretend hello-world-wrapper is
# missing and hello-world is outdated
func_orig = pmb.parse.apkindex.package
def func_patch(args, package, *args2, **kwargs):
def func_patch(args: PmbArgs, package, *args2, **kwargs):
print(f"func_patch: called for package: {package}")
if package == "hello-world-wrapper":
print("pretending that it does not exist")
@ -206,7 +206,7 @@ def test_build_depends_binary_outdated(args, monkeypatch):
assert "'hello-world' of 'hello-world-wrapper' is outdated" in str(e.value)
def test_is_necessary_warn_depends(args, monkeypatch):
def test_is_necessary_warn_depends(args: PmbArgs, monkeypatch):
# Shortcut and fake apkbuild
func = pmb.build._package.is_necessary_warn_depends
apkbuild = {"pkgname": "test"}
@ -224,7 +224,7 @@ def test_is_necessary_warn_depends(args, monkeypatch):
assert func(args, apkbuild, "armhf", False, ["first", "second"]) is False
def test_init_buildenv(args, monkeypatch):
def test_init_buildenv(args: PmbArgs, monkeypatch):
# First init native chroot buildenv properly without patched functions
pmb.build.init(args)
@ -261,7 +261,7 @@ def test_get_pkgver(monkeypatch):
assert func("1.0_git20170101", False, now) == "1.0_p20180101000000"
def test_run_abuild(args, monkeypatch):
def test_run_abuild(args: PmbArgs, monkeypatch):
# Disable effects of functions we don't want to test here
monkeypatch.setattr(pmb.build, "copy_to_buildpath", return_none)
monkeypatch.setattr(pmb.chroot, "user", return_none)
@ -294,7 +294,7 @@ def test_run_abuild(args, monkeypatch):
assert func(args, apkbuild, "armhf", cross="native") == (output, cmd, env)
def test_finish(args, monkeypatch):
def test_finish(args: PmbArgs, monkeypatch):
# Real output path
output = pmb.build.package(args, "hello-world", force=True)
@ -335,13 +335,13 @@ def test_package(args):
assert pmb.build.package(args, "alpine-base") is None
def test_build_depends_high_level(args, monkeypatch):
def test_build_depends_high_level(args: PmbArgs, monkeypatch):
"""
"hello-world-wrapper" depends on "hello-world". We build both, then delete
"hello-world" and check that it gets rebuilt correctly again.
"""
# Patch pmb.build.is_necessary() to always build the hello-world package
def fake_build_is_necessary(args, arch, apkbuild, apkindex_path=None):
def fake_build_is_necessary(args: PmbArgs, arch, apkbuild, apkindex_path=None):
if apkbuild["pkgname"] == "hello-world":
return True
return pmb.build.other.is_necessary(args, arch, apkbuild,
@ -370,7 +370,7 @@ def test_build_depends_high_level(args, monkeypatch):
assert os.path.exists(output_hello_outside)
def test_build_local_source_high_level(args, tmpdir):
def test_build_local_source_high_level(args: PmbArgs, tmpdir):
"""
Test building a package with overriding the source code:
pmbootstrap build --src=/some/path hello-world
@ -437,7 +437,7 @@ def test_build_local_source_high_level(args, tmpdir):
pmb.helpers.run.root(args, ["rm", "-r", tmpdir])
def test_build_abuild_leftovers(args, tmpdir):
def test_build_abuild_leftovers(args: PmbArgs, tmpdir):
"""
Test building a package with having abuild leftovers, that will error if
copied:

View file

@ -24,7 +24,7 @@ def args(request):
return args
def test_switch_to_channel_branch(args, monkeypatch, tmpdir):
def test_switch_to_channel_branch(args: PmbArgs, monkeypatch, tmpdir):
path, run_git = pmb_test.git.prepare_tmpdir(args, monkeypatch, tmpdir)
args.aports = path
@ -50,7 +50,7 @@ def test_switch_to_channel_branch(args, monkeypatch, tmpdir):
assert branch == "v20.05"
def test_read_config_channel(args, monkeypatch):
def test_read_config_channel(args: PmbArgs, monkeypatch):
channel = "edge"
# Pretend to have a certain channel in pmaports.cfg

View file

@ -34,7 +34,7 @@ def args_patched(monkeypatch, argv):
return pmb.parse.arguments()
def test_config_user(args, tmpdir, monkeypatch):
def test_config_user(args: PmbArgs, tmpdir, monkeypatch):
# Temporary paths
tmpdir = str(tmpdir)
path_work = tmpdir + "/work"

View file

@ -23,7 +23,7 @@ def args(request):
return args
def test_chroot_save_init(args, tmpdir, monkeypatch):
def test_chroot_save_init(args: PmbArgs, tmpdir, monkeypatch):
# Override time.time()
def fake_time():
return 1234567890.1234
@ -57,7 +57,7 @@ def test_chroot_save_init(args, tmpdir, monkeypatch):
assert handle.read() == expected
def test_chroots_outdated(args, tmpdir, monkeypatch):
def test_chroots_outdated(args: PmbArgs, tmpdir, monkeypatch):
args.work = str(tmpdir)
# Override time.time(): now is "100"
@ -87,7 +87,7 @@ def test_chroots_outdated(args, tmpdir, monkeypatch):
assert func(args) is False
def test_chroot_check_channel(args, tmpdir, monkeypatch):
def test_chroot_check_channel(args: PmbArgs, tmpdir, monkeypatch):
func = pmb.config.workdir.chroot_check_channel
args.work = str(tmpdir)
channel = "edge"
@ -122,7 +122,7 @@ def test_chroot_check_channel(args, tmpdir, monkeypatch):
func(args, "native")
def test_clean(args, tmpdir):
def test_clean(args: PmbArgs, tmpdir):
args.work = str(tmpdir)
# 0. workdir.cfg does not exist

View file

@ -22,7 +22,7 @@ def args(request):
return args
def test_file_is_older_than(args, tmpdir):
def test_file_is_older_than(args: PmbArgs, tmpdir):
# Create a file last modified 10s ago
tempfile = str(tmpdir) + "/test"
pmb.helpers.run.user(args, ["touch", tempfile])

View file

@ -19,7 +19,7 @@ def args(request):
return args
def test_get_folder_size(args, tmpdir):
def test_get_folder_size(args: PmbArgs, tmpdir):
# Write five 200 KB files to tmpdir
tmpdir = str(tmpdir)
files = 5

View file

@ -34,7 +34,7 @@ def test_get_path(args):
assert func(args, "pmaports") == "/tmp/pmaports"
def test_can_fast_forward(args, tmpdir):
def test_can_fast_forward(args: PmbArgs, tmpdir):
tmpdir = str(tmpdir)
func = pmb.helpers.git.can_fast_forward
branch_origin = "fake-branch-origin"
@ -62,7 +62,7 @@ def test_can_fast_forward(args, tmpdir):
assert str(e.value).startswith("Unexpected exit code")
def test_clean_worktree(args, tmpdir):
def test_clean_worktree(args: PmbArgs, tmpdir):
tmpdir = str(tmpdir)
func = pmb.helpers.git.clean_worktree
@ -78,13 +78,13 @@ def test_clean_worktree(args, tmpdir):
assert func(args, tmpdir) is False
def test_get_upstream_remote(args, monkeypatch, tmpdir):
def test_get_upstream_remote(args: PmbArgs, monkeypatch, tmpdir):
tmpdir = str(tmpdir)
func = pmb.helpers.git.get_upstream_remote
name_repo = "test"
# Override get_path()
def get_path(args, name_repo):
def get_path(args: PmbArgs, name_repo):
return tmpdir
monkeypatch.setattr(pmb.helpers.git, "get_path", get_path)
@ -130,7 +130,7 @@ def test_pull_non_existing(args):
assert pmb.helpers.git.pull(args, "non-existing-repo-name") == 1
def test_pull(args, monkeypatch, tmpdir):
def test_pull(args: PmbArgs, monkeypatch, tmpdir):
""" Test pmb.helpers.git.pull """
path, run_git = pmb_test.git.prepare_tmpdir(args, monkeypatch, tmpdir)

View file

@ -22,7 +22,7 @@ def args(request):
return args
def test_pmbootstrap_lint(args, tmpdir):
def test_pmbootstrap_lint(args: PmbArgs, tmpdir):
args.aports = tmpdir = str(tmpdir)
# Create hello-world pmaport in tmpdir

View file

@ -19,11 +19,11 @@ def args(request):
return args
def test_helpers_package_get_pmaports_and_cache(args, monkeypatch):
def test_helpers_package_get_pmaports_and_cache(args: PmbArgs, monkeypatch):
""" Test pmb.helpers.package.get(): find in pmaports, use cached result """
# Fake APKBUILD data
def stub(args, pkgname, must_exist):
def stub(args: PmbArgs, pkgname, must_exist):
return {"arch": ["armv7"],
"depends": ["testdepend"],
"pkgname": "testpkgname",
@ -49,7 +49,7 @@ def test_helpers_package_get_pmaports_and_cache(args, monkeypatch):
assert func(args, "testpkgname", "armv7") == package
def test_helpers_package_get_apkindex(args, monkeypatch):
def test_helpers_package_get_apkindex(args: PmbArgs, monkeypatch):
""" Test pmb.helpers.package.get(): find in apkindex """
# Fake APKINDEX data
@ -59,7 +59,7 @@ def test_helpers_package_get_apkindex(args, monkeypatch):
"provides": ["testprovide"],
"version": "1.0-r1"}
def stub(args, pkgname, arch, must_exist):
def stub(args: PmbArgs, pkgname, arch, must_exist):
if arch != fake_apkindex_data["arch"]:
return None
return fake_apkindex_data
@ -121,12 +121,12 @@ def test_helpers_package_check_arch_package(args):
assert func(args, "a", "armhf") is False
def test_helpers_package_check_arch_pmaports(args, monkeypatch):
def test_helpers_package_check_arch_pmaports(args: PmbArgs, monkeypatch):
""" Test pmb.helpers.package.check_arch(): binary = False """
func = pmb.helpers.package.check_arch
fake_pmaport = {"arch": []}
def fake_pmaports_get(args, pkgname, must_exist=False):
def fake_pmaports_get(args: PmbArgs, pkgname, must_exist=False):
return fake_pmaport
monkeypatch.setattr(pmb.helpers.pmaports, "get", fake_pmaports_get)

View file

@ -19,7 +19,7 @@ def args(request):
return args
def test_guess_main(args, tmpdir):
def test_guess_main(args: PmbArgs, tmpdir):
# Fake pmaports folder
tmpdir = str(tmpdir)
args.aports = tmpdir
@ -35,7 +35,7 @@ def test_guess_main(args, tmpdir):
assert func(args, "qemuPackageWithoutDashes") is None
def test_guess_main_dev(args, tmpdir):
def test_guess_main_dev(args: PmbArgs, tmpdir):
# Fake pmaports folder
tmpdir = str(tmpdir)
args.aports = tmpdir

View file

@ -34,7 +34,7 @@ def test_alpine_apkindex_path(args):
assert func(args, "testing", "armhf") == ret
def test_urls(args, monkeypatch):
def test_urls(args: PmbArgs, monkeypatch):
func = pmb.helpers.repo.urls
channel = "v20.05"
args.mirror_alpine = "http://localhost/alpine/"

View file

@ -32,12 +32,12 @@ def test_filter_missing_packages_binary_exists(args):
assert func(args, "armhf", ["busybox"]) == []
def test_filter_missing_packages_pmaports(args, monkeypatch):
def test_filter_missing_packages_pmaports(args: PmbArgs, monkeypatch):
""" Test ...repo_missing.filter_missing_packages(): pmaports """
build_is_necessary = None
func = pmb.helpers.repo_missing.filter_missing_packages
def stub(args, arch, pmaport):
def stub(args: PmbArgs, arch, pmaport):
return build_is_necessary
monkeypatch.setattr(pmb.build, "is_necessary", stub)
@ -54,12 +54,12 @@ def test_filter_aport_packages(args):
assert func(args, "armhf", ["busybox", "hello-world"]) == ["hello-world"]
def test_filter_arch_packages(args, monkeypatch):
def test_filter_arch_packages(args: PmbArgs, monkeypatch):
""" Test ...repo_missing.filter_arch_packages() """
func = pmb.helpers.repo_missing.filter_arch_packages
check_arch = None
def stub(args, arch, pmaport, binary=True):
def stub(args: PmbArgs, arch, pmaport, binary=True):
return check_arch
monkeypatch.setattr(pmb.helpers.package, "check_arch", stub)
@ -70,7 +70,7 @@ def test_filter_arch_packages(args, monkeypatch):
assert func(args, "armhf", []) == []
def test_get_relevant_packages(args, monkeypatch):
def test_get_relevant_packages(args: PmbArgs, monkeypatch):
""" Test ...repo_missing.get_relevant_packages() """
# Set up fake return values
@ -80,24 +80,24 @@ def test_get_relevant_packages(args, monkeypatch):
"filter_aport_packages": ["b", "a"],
"filter_missing_packages": ["a"]}
def stub(args, arch, pmaport, binary=True):
def stub(args: PmbArgs, arch, pmaport, binary=True):
return stub_data["check_arch"]
monkeypatch.setattr(pmb.helpers.package, "check_arch", stub)
def stub(args, arch, pmaport):
def stub(args: PmbArgs, arch, pmaport):
return stub_data["depends_recurse"]
monkeypatch.setattr(pmb.helpers.package, "depends_recurse", stub)
def stub(args, arch, pmaport):
def stub(args: PmbArgs, arch, pmaport):
return stub_data["filter_arch_packages"]
monkeypatch.setattr(pmb.helpers.repo_missing, "filter_arch_packages", stub)
def stub(args, arch, pmaport):
def stub(args: PmbArgs, arch, pmaport):
return stub_data["filter_aport_packages"]
monkeypatch.setattr(pmb.helpers.repo_missing, "filter_aport_packages",
stub)
def stub(args, arch, pmaport):
def stub(args: PmbArgs, arch, pmaport):
return stub_data["filter_missing_packages"]
monkeypatch.setattr(pmb.helpers.repo_missing, "filter_missing_packages",
stub)
@ -118,15 +118,15 @@ def test_get_relevant_packages(args, monkeypatch):
assert func(args, "armhf", "a", True) == ["a", "b"]
def test_generate_output_format(args, monkeypatch):
def test_generate_output_format(args: PmbArgs, monkeypatch):
""" Test ...repo_missing.generate_output_format() """
def stub(args, pkgname, arch, replace_subpkgnames=False):
def stub(args: PmbArgs, pkgname, arch, replace_subpkgnames=False):
return {"pkgname": "hello-world", "version": "1.0-r0",
"depends": ["depend1", "depend2"]}
monkeypatch.setattr(pmb.helpers.package, "get", stub)
def stub(args, pkgname):
def stub(args: PmbArgs, pkgname):
return "main"
monkeypatch.setattr(pmb.helpers.pmaports, "get_repo", stub)

View file

@ -26,7 +26,7 @@ def args(tmpdir, request):
return args
def test_newapkbuild(args, monkeypatch, tmpdir):
def test_newapkbuild(args: PmbArgs, monkeypatch, tmpdir):
testdata = pmb_test.const.testdata
# Fake functions

View file

@ -208,7 +208,7 @@ def test_parse_invalid_path():
assert pmb.parse.apkindex.parse("/invalid/path/APKINDEX") == {}
def test_parse_cached(args, tmpdir):
def test_parse_cached(args: PmbArgs, tmpdir):
# Create a real file (cache looks at the last modified date)
path = str(tmpdir) + "/APKINDEX"
pmb.helpers.run.user(args, ["touch", path])
@ -293,7 +293,7 @@ def test_parse_virtual():
assert pmb.helpers.other.cache["apkindex"][path]["single"] == ret
def test_providers_invalid_package(args, tmpdir):
def test_providers_invalid_package(args: PmbArgs, tmpdir):
# Create empty APKINDEX
path = str(tmpdir) + "/APKINDEX"
pmb.helpers.run.user(args, ["touch", path])
@ -310,7 +310,7 @@ def test_providers_invalid_package(args, tmpdir):
assert str(e.value).startswith("Could not find package")
def test_providers_highest_version(args, monkeypatch):
def test_providers_highest_version(args: PmbArgs, monkeypatch):
"""
In this test, we simulate 3 APKINDEX files ("i0", "i1", "i2" instead of
full paths to real APKINDEX.tar.gz files), and each of them has a different
@ -330,7 +330,7 @@ def test_providers_highest_version(args, monkeypatch):
assert providers["test"]["version"] == "3"
def test_provider_highest_priority(args, monkeypatch):
def test_provider_highest_priority(args: PmbArgs, monkeypatch):
# Verify that it picks the provider with highest priority
func = pmb.parse.apkindex.provider_highest_priority
@ -367,7 +367,7 @@ def test_provider_highest_priority(args, monkeypatch):
assert func(providers2, "test") == providers
def test_package(args, monkeypatch):
def test_package(args: PmbArgs, monkeypatch):
# Override pmb.parse.apkindex.providers()
providers = collections.OrderedDict()

View file

@ -31,7 +31,7 @@ def test_package_from_aports(args):
"version": "1-r6"}
def test_package_provider(args, monkeypatch):
def test_package_provider(args: PmbArgs, monkeypatch):
# Override pmb.parse.apkindex.providers()
providers = collections.OrderedDict()
@ -85,7 +85,7 @@ def test_package_provider(args, monkeypatch):
assert func(args, pkgname, pkgnames_install) == package
def test_package_from_index(args, monkeypatch):
def test_package_from_index(args: PmbArgs, monkeypatch):
# Override pmb.parse.depends.package_provider()
provider = None
@ -112,7 +112,7 @@ def test_package_from_index(args, monkeypatch):
assert func(args, pkgname, pkgnames_install, aport) is provider
def test_recurse_invalid(args, monkeypatch):
def test_recurse_invalid(args: PmbArgs, monkeypatch):
func = pmb.parse.depends.recurse
# Invalid package
@ -125,7 +125,7 @@ def return_none(*args, **kwargs):
return None
def test_recurse(args, monkeypatch):
def test_recurse(args: PmbArgs, monkeypatch):
"""
Test recursing through the following dependencies:
@ -151,7 +151,7 @@ def test_recurse(args, monkeypatch):
"so:libtest.so.1": ["libtest_depend"],
}
def package_from_index(args, pkgname, install, aport, suffix):
def package_from_index(args: PmbArgs, pkgname, install, aport, suffix):
if pkgname in depends:
return {"pkgname": pkgname, "depends": depends[pkgname]}
else:

View file

@ -309,7 +309,7 @@ def test_check_config(monkeypatch, tmpdir):
assert func(path, arch, pkgver, components_list, details, enforce) is True
def test_check(args, monkeypatch, tmpdir):
def test_check(args: PmbArgs, monkeypatch, tmpdir):
func = pmb.parse.kconfig.check
details = True
components_list = []

View file

@ -23,7 +23,7 @@ def args(request):
return args
def pmbootstrap(args, tmpdir, parameters, zero_exit=True):
def pmbootstrap(args: PmbArgs, tmpdir, parameters, zero_exit=True):
"""
Helper function for running pmbootstrap inside the fake work folder
(created by setup() below) with the binary repo disabled and with the
@ -57,7 +57,7 @@ def pmbootstrap(args, tmpdir, parameters, zero_exit=True):
raise RuntimeError("Expected pmbootstrap to fail, but it did not!")
def setup_work(args, tmpdir):
def setup_work(args: PmbArgs, tmpdir):
"""
Create fake work folder in tmpdir with everything symlinked except for the
built packages. The aports testdata gets copied to the tempfolder as
@ -123,7 +123,7 @@ def verify_pkgrels(tmpdir, pkgrel_testlib, pkgrel_testapp,
assert pkgrel == int(apkbuild["pkgrel"])
def test_pkgrel_bump_high_level(args, tmpdir):
def test_pkgrel_bump_high_level(args: PmbArgs, tmpdir):
# Tempdir setup
tmpdir = str(tmpdir)
setup_work(args, tmpdir)

View file

@ -24,28 +24,28 @@ def args(request):
return args
def test_proxy_user(args, monkeypatch):
def test_proxy_user(args: PmbArgs, monkeypatch):
func = pmb.helpers.run.user
monkeypatch.setattr(os, "environ", {"HTTP_PROXY": "testproxy"})
ret = func(args, ["sh", "-c", 'echo "$HTTP_PROXY"'], output_return=True)
assert ret == "testproxy\n"
def test_proxy_root(args, monkeypatch):
def test_proxy_root(args: PmbArgs, monkeypatch):
func = pmb.helpers.run.root
monkeypatch.setattr(os, "environ", {"HTTP_PROXY": "testproxy"})
ret = func(args, ["sh", "-c", 'echo "$HTTP_PROXY"'], output_return=True)
assert ret == "testproxy\n"
def test_proxy_chroot_user(args, monkeypatch):
def test_proxy_chroot_user(args: PmbArgs, monkeypatch):
func = pmb.chroot.user
monkeypatch.setattr(os, "environ", {"HTTP_PROXY": "testproxy"})
ret = func(args, ["sh", "-c", 'echo "$HTTP_PROXY"'], output_return=True)
assert ret == "testproxy\n"
def test_proxy_chroot_root(args, monkeypatch):
def test_proxy_chroot_root(args: PmbArgs, monkeypatch):
func = pmb.chroot.root
monkeypatch.setattr(os, "environ", {"HTTP_PROXY": "testproxy"})
ret = func(args, ["sh", "-c", 'echo "$HTTP_PROXY"'], output_return=True)

View file

@ -39,14 +39,14 @@ def ssh_create_askpass_script(args):
pmb.chroot.root(args, ["chmod", "+x", "/tmp/y.sh"])
def pmbootstrap_run(args, config, parameters, output="log"):
def pmbootstrap_run(args: PmbArgs, config, parameters, output="log"):
"""Execute pmbootstrap.py with a test pmbootstrap.conf."""
return pmb.helpers.run.user(args, ["./pmbootstrap.py", "-c", config] +
parameters, working_dir=pmb.config.pmb_src,
output=output)
def pmbootstrap_yes(args, config, parameters):
def pmbootstrap_yes(args: PmbArgs, config, parameters):
"""
Execute pmbootstrap.py with a test pmbootstrap.conf, and pipe "yes" into it
(so we can do a fully automated installation, using "y" as password
@ -100,7 +100,7 @@ def qemu(request):
return QEMU(request)
def ssh_run(args, command):
def ssh_run(args: PmbArgs, command):
"""
Run a command in the QEMU VM on localhost via SSH.
@ -116,7 +116,7 @@ def ssh_run(args, command):
return ret
def is_running(args, programs, timeout=300, sleep_before_retry=1):
def is_running(args: PmbArgs, programs, timeout=300, sleep_before_retry=1):
"""
Simple check that looks for program names in the output of "ps ax".
This is error-prone, only use it with programs that have a unique name.
@ -165,7 +165,7 @@ def is_running(args, programs, timeout=300, sleep_before_retry=1):
@pytest.mark.skip_ci
def test_none(args, tmpdir, qemu):
def test_none(args: PmbArgs, tmpdir, qemu):
qemu.run(args, tmpdir)
# Check that at least SSH works (no special process running)
@ -177,14 +177,14 @@ def test_none(args, tmpdir, qemu):
@pytest.mark.skip_ci
def test_xfce4(args, tmpdir, qemu):
def test_xfce4(args: PmbArgs, tmpdir, qemu):
qemu.run(args, tmpdir, "xfce4")
assert is_running(args, ["xfce4-session", "xfdesktop", "xfce4-panel",
"Thunar", "dbus-daemon", "xfwm4"])
@pytest.mark.skip_ci
def test_plasma_mobile(args, tmpdir, qemu):
def test_plasma_mobile(args: PmbArgs, tmpdir, qemu):
# NOTE: Once we have plasma mobile running properly without GL, we can
# check for more processes
qemu.run(args, tmpdir, "plasma-mobile")

View file

@ -49,7 +49,7 @@ def test_fake_answers_selftest(monkeypatch):
assert pmb.helpers.cli.ask() == "second"
def test_questions_booleans(args, monkeypatch):
def test_questions_booleans(args: PmbArgs, monkeypatch):
functions = [pmb.aportgen.device.ask_for_keyboard,
pmb.aportgen.device.ask_for_external_storage]
for func in functions:
@ -58,14 +58,14 @@ def test_questions_booleans(args, monkeypatch):
assert func(args) is False
def test_questions_strings(args, monkeypatch):
def test_questions_strings(args: PmbArgs, monkeypatch):
functions = [pmb.aportgen.device.ask_for_manufacturer]
for func in functions:
fake_answers(monkeypatch, ["Simple string answer"])
assert func() == "Simple string answer"
def test_questions_name(args, monkeypatch):
def test_questions_name(args: PmbArgs, monkeypatch):
func = pmb.aportgen.device.ask_for_name
# Manufacturer should get added automatically, but not twice
@ -79,12 +79,12 @@ def test_questions_name(args, monkeypatch):
assert func("Amazon") == "Google Nexus 12345"
def test_questions_arch(args, monkeypatch):
def test_questions_arch(args: PmbArgs, monkeypatch):
fake_answers(monkeypatch, ["invalid_arch", "aarch64"])
assert pmb.aportgen.device.ask_for_architecture() == "aarch64"
def test_questions_bootimg(args, monkeypatch):
def test_questions_bootimg(args: PmbArgs, monkeypatch):
func = pmb.aportgen.device.ask_for_bootimg
fake_answers(monkeypatch, ["invalid_path", ""])
assert func(args) is None
@ -104,14 +104,14 @@ def test_questions_bootimg(args, monkeypatch):
assert func(args) == output
def test_questions_device(args, monkeypatch):
def test_questions_device(args: PmbArgs, monkeypatch):
# Prepare args
args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
args.device = "lg-mako"
args.kernel = "downstream"
# Do not generate aports
def fake_generate(args, pkgname):
def fake_generate(args: PmbArgs, pkgname):
return
monkeypatch.setattr(pmb.aportgen, "generate", fake_generate)
@ -138,7 +138,7 @@ def test_questions_device(args, monkeypatch):
assert func(args) == ("lg-nonexistent", False, kernel)
def test_questions_device_kernel(args, monkeypatch):
def test_questions_device_kernel(args: PmbArgs, monkeypatch):
# Prepare args
args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
args.kernel = "downstream"
@ -158,7 +158,7 @@ def test_questions_device_kernel(args, monkeypatch):
assert func(args, device) == "downstream"
def test_questions_flash_methods(args, monkeypatch):
def test_questions_flash_methods(args: PmbArgs, monkeypatch):
func = pmb.aportgen.device.ask_for_flash_method
fake_answers(monkeypatch, ["invalid_flash_method", "fastboot"])
assert func() == "fastboot"
@ -173,14 +173,14 @@ def test_questions_flash_methods(args, monkeypatch):
assert func() == "heimdall-bootimg"
def test_questions_keymaps(args, monkeypatch):
def test_questions_keymaps(args: PmbArgs, monkeypatch):
func = pmb.config.init.ask_for_keymaps
fake_answers(monkeypatch, ["invalid_keymap", "us/rx51_us"])
assert func(args, pmb.parse.deviceinfo(args, "nokia-n900")) == "us/rx51_us"
assert func(args, pmb.parse.deviceinfo(args, "lg-mako")) == ""
def test_questions_ui(args, monkeypatch):
def test_questions_ui(args: PmbArgs, monkeypatch):
args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
device = "lg-mako"
info = pmb.parse.deviceinfo(args, device)
@ -192,7 +192,7 @@ def test_questions_ui(args, monkeypatch):
assert pmb.config.init.ask_for_ui(args, info) == "weston"
def test_questions_ui_extras(args, monkeypatch):
def test_questions_ui_extras(args: PmbArgs, monkeypatch):
args.aports = pmb_test.const.testdata + "/init_questions_device/aports"
assert not pmb.config.init.ask_for_ui_extras(args, "none")
@ -203,7 +203,7 @@ def test_questions_ui_extras(args, monkeypatch):
assert pmb.config.init.ask_for_ui_extras(args, "weston")
def test_questions_work_path(args, monkeypatch, tmpdir):
def test_questions_work_path(args: PmbArgs, monkeypatch, tmpdir):
# Existing paths (triggering various errors)
func = pmb.config.init.ask_for_work_path
tmpdir = str(tmpdir)
@ -217,7 +217,7 @@ def test_questions_work_path(args, monkeypatch, tmpdir):
assert func(args) == (work, False)
def test_questions_additional_options(args, monkeypatch):
def test_questions_additional_options(args: PmbArgs, monkeypatch):
func = pmb.config.init.ask_for_additional_options
cfg = {"pmbootstrap": {}}
@ -239,7 +239,7 @@ def test_questions_additional_options(args, monkeypatch):
"mirrors_postmarketos": mirror}}
def test_questions_hostname(args, monkeypatch):
def test_questions_hostname(args: PmbArgs, monkeypatch):
func = pmb.config.init.ask_for_hostname
device = "test-device"
@ -264,6 +264,6 @@ def test_questions_hostname(args, monkeypatch):
assert func(args, device) == ""
def test_questions_channel(args, monkeypatch):
def test_questions_channel(args: PmbArgs, monkeypatch):
fake_answers(monkeypatch, ["invalid-channel", "v20.05"])
assert pmb.config.init.ask_for_channel(args) == "v20.05"

View file

@ -127,7 +127,7 @@ def test_foreground_tui():
assert func(["echo", "test"]) == 0
def test_core(args, monkeypatch):
def test_core(args: PmbArgs, monkeypatch):
# Background
func = pmb.helpers.run_core.core
msg = "test"