1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-13 03:19:47 +03:00

make mypy happy (MR 2252)

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-13 05:35:30 +02:00 committed by Oliver Smith
parent f2ca9c618e
commit 0365438134
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
10 changed files with 19 additions and 14 deletions

View file

@ -6,6 +6,7 @@
import sys import sys
import os import os
import datetime import datetime
from typing import Any, Dict
sys.path.insert(0, os.path.abspath('..')) # Allow modules to be found sys.path.insert(0, os.path.abspath('..')) # Allow modules to be found
@ -41,7 +42,7 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
html_theme = 'sphinx_rtd_theme' html_theme = 'sphinx_rtd_theme'
html_favicon = 'https://wiki.postmarketos.org/favicon.ico' html_favicon = 'https://wiki.postmarketos.org/favicon.ico'
html_theme_options = {'style_nav_header_background': '008b69',} html_theme_options: Dict[str, Any] = {'style_nav_header_background': '008b69',}
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'pmboostrapdoc' htmlhelp_basename = 'pmboostrapdoc'

View file

@ -92,4 +92,4 @@ def generate(pkgname: str, fork_alpine: bool):
pmb.helpers.run.user( pmb.helpers.run.user(
["mv", aportgen, path_target]) ["mv", aportgen, path_target])
logging.info("*** pmaport generated: " + path_target) logging.info(f"*** pmaport generated: {path_target}")

View file

@ -60,7 +60,7 @@ def generate_apkbuild(pkgname: str, deviceinfo: Deviceinfo, patches: List[str]):
makedepends.sort() makedepends.sort()
makedepends_fmt = ("\n" + " " * 12).join(makedepends) makedepends_fmt = ("\n" + " " * 12).join(makedepends)
patches = ("\n" + " " * 12).join(patches) patches_str = ("\n" + " " * 12).join(patches)
content = f"""\ content = f"""\
# Reference: <https://postmarketos.org/vendorkernel> # Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/{carch}/configs/(CHANGEME!) # Kernel config based on: arch/{carch}/configs/(CHANGEME!)
@ -86,7 +86,7 @@ def generate_apkbuild(pkgname: str, deviceinfo: Deviceinfo, patches: List[str]):
source=" source="
$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz $pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
$_config $_config
{patches} {patches_str}
" "
builddir="$srcdir/$_repository-$_commit" builddir="$srcdir/$_repository-$_commit"
_outdir="out" _outdir="out"

View file

@ -140,6 +140,8 @@ def packages_get_locally_built_apks(packages, arch: Arch) -> List[Path]:
return ret return ret
# FIXME: List[Sequence[PathString]] weirdness
# mypy: disable-error-code="operator"
def install_run_apk(to_add: List[str], to_add_local: List[Path], to_del: List[str], chroot: Chroot): def install_run_apk(to_add: List[str], to_add_local: List[Path], to_del: List[str], chroot: Chroot):
""" """
Run apk to add packages, and ensure only the desired packages get Run apk to add packages, and ensure only the desired packages get

View file

@ -116,6 +116,8 @@ def flash_lk2nd(deviceinfo: Deviceinfo, method: str):
# Get the lk2nd package (which is a dependency of the device package) # Get the lk2nd package (which is a dependency of the device package)
device_pkg = f"device-{deviceinfo.codename}" device_pkg = f"device-{deviceinfo.codename}"
apkbuild = pmb.helpers.pmaports.get(device_pkg) apkbuild = pmb.helpers.pmaports.get(device_pkg)
if not apkbuild:
raise RuntimeError(f"Failed to find {device_pkg} in pmaports")
lk2nd_pkg = None lk2nd_pkg = None
for dep in apkbuild["depends"]: for dep in apkbuild["depends"]:
if dep.startswith("lk2nd"): if dep.startswith("lk2nd"):

View file

@ -551,9 +551,7 @@ def qemu(args: PmbArgs):
def stats(args: PmbArgs): def stats(args: PmbArgs):
# Chroot suffix # Chroot suffix
chroot = Chroot.native() chroot = Chroot.buildroot(args.arch or Arch.native())
if args.arch != Arch.native():
chroot = Chroot.buildroot(args.arch)
# Install ccache and display stats # Install ccache and display stats
pmb.chroot.apk.install(["ccache"], chroot) pmb.chroot.apk.install(["ccache"], chroot)

View file

@ -12,7 +12,9 @@ import pmb.build
import pmb.helpers.run import pmb.helpers.run
import pmb.helpers.pmaports import pmb.helpers.pmaports
# FIXME: dest_paths[repo], repo expected to be a Literal.
# We should really make Config.mirrors not a TypedDict.
# mypy: disable-error-code="index"
def check(pkgnames: Sequence[str]): def check(pkgnames: Sequence[str]):
"""Run apkbuild-lint on the supplied packages. """Run apkbuild-lint on the supplied packages.
@ -54,7 +56,7 @@ def check(pkgnames: Sequence[str]):
options = pmb.config.apkbuild_custom_valid_options options = pmb.config.apkbuild_custom_valid_options
# For each pkgrepo run the linter on the relevant packages # For each pkgrepo run the linter on the relevant packages
for repo, apkbuild_paths in apkbuilds.items(): for pkgrepo, apkbuild_paths in apkbuilds.items():
pmb.chroot.root(["apkbuild-lint"] + apkbuild_paths, pmb.chroot.root(["apkbuild-lint"] + apkbuild_paths,
check=False, output="stdout", check=False, output="stdout",
output_return=True, output_return=True,

View file

@ -233,7 +233,7 @@ def get_with_path(pkgname, must_exist=True, subpackages=True, skip_extra_repos=F
return None, None return None, None
def get(pkgname, must_exist=True, subpackages=True, skip_extra_repos=False) -> Optional[Dict[str, Any]]: def get(pkgname, must_exist=True, subpackages=True, skip_extra_repos=False) -> Dict[str, Any]:
return get_with_path(pkgname, must_exist, subpackages, skip_extra_repos)[1] return get_with_path(pkgname, must_exist, subpackages, skip_extra_repos)[1]

View file

@ -50,6 +50,8 @@ def apkindex_hash(url: str, length: int=8) -> Path:
return Path(f"APKINDEX.{ret}.tar.gz") return Path(f"APKINDEX.{ret}.tar.gz")
# FIXME: make config.mirrors a normal dict
# mypy: disable-error-code="literal-required"
@Cache("user_repository", "mirrors_exclude") @Cache("user_repository", "mirrors_exclude")
def urls(user_repository=True, mirrors_exclude: List[str] = []): def urls(user_repository=True, mirrors_exclude: List[str] = []):
"""Get a list of repository URLs, as they are in /etc/apk/repositories. """Get a list of repository URLs, as they are in /etc/apk/repositories.
@ -82,7 +84,7 @@ def urls(user_repository=True, mirrors_exclude: List[str] = []):
for repo in pkgrepo_names() + ["alpine"]: for repo in pkgrepo_names() + ["alpine"]:
if repo in mirrors_exclude: if repo in mirrors_exclude:
continue continue
mirror = config.mirrors[repo] # mypy: disable-error-code="literal-required" mirror = config.mirrors[repo]
mirrordirs = [] mirrordirs = []
if repo == "alpine": if repo == "alpine":
# FIXME: This is a bit of a mess # FIXME: This is a bit of a mess

View file

@ -72,9 +72,7 @@ class PmbArgs(Namespace):
flash_method: str flash_method: str
folder: str folder: str
force: bool force: bool
fork_alpine: str fork_alpine: bool
# This is a filthy lie
from_argparse: "PmbArgs"
full_disk_encryption: str full_disk_encryption: str
hook: str hook: str
host: str host: str