forked from Mirror/pmbootstrap
pmb: Reformat with Ruff 0.9 (MR 2525)
See https://astral.sh/blog/ruff-v0.9.0
This commit is contained in:
parent
2be49f8caf
commit
3061e702ab
48 changed files with 114 additions and 145 deletions
|
@ -195,7 +195,7 @@ def parse_next_attribute(
|
|||
i += 1
|
||||
|
||||
raise RuntimeError(
|
||||
f"Can't find closing quote sign ({end_char}) for" f" attribute '{attribute}' in: {path}"
|
||||
f"Can't find closing quote sign ({end_char}) for attribute '{attribute}' in: {path}"
|
||||
)
|
||||
|
||||
|
||||
|
@ -363,7 +363,7 @@ def apkbuild(path: Path, check_pkgver: bool = True, check_pkgname: bool = True)
|
|||
logging.info(f"Folder: '{os.path.dirname(path)}'")
|
||||
logging.info(f"Pkgname: '{ret['pkgname']}'")
|
||||
raise RuntimeError(
|
||||
"The pkgname must be equal to the name of" " the folder that contains the APKBUILD!"
|
||||
"The pkgname must be equal to the name of the folder that contains the APKBUILD!"
|
||||
)
|
||||
|
||||
# Sanity check: pkgver
|
||||
|
@ -373,7 +373,7 @@ def apkbuild(path: Path, check_pkgver: bool = True, check_pkgname: bool = True)
|
|||
"NOTE: Valid pkgvers are described here: "
|
||||
"https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#pkgver"
|
||||
)
|
||||
raise RuntimeError(f"Invalid pkgver '{ret['pkgver']}' in" f" APKBUILD: {path}")
|
||||
raise RuntimeError(f"Invalid pkgver '{ret['pkgver']}' in APKBUILD: {path}")
|
||||
|
||||
# Fill cache
|
||||
return ret
|
||||
|
|
|
@ -70,7 +70,7 @@ def parse_next_block(path: Path, lines: list[str]) -> ApkindexBlock | None:
|
|||
if required_found != len(required_apkindex_keys):
|
||||
for key in required_apkindex_keys:
|
||||
if key not in ret:
|
||||
raise RuntimeError(f"Missing required key '{key}' in block " f"{ret}, file: {path}")
|
||||
raise RuntimeError(f"Missing required key '{key}' in block {ret}, file: {path}")
|
||||
raise RuntimeError(
|
||||
f"Expected {len(required_apkindex_keys)} required keys,"
|
||||
f" but found {required_found} in block: {ret}, file: {path}"
|
||||
|
@ -274,7 +274,7 @@ def parse(
|
|||
|
||||
# Skip virtual packages
|
||||
if block.timestamp is None:
|
||||
logging.verbose(f"Skipped virtual package {block} in" f" file: {path}")
|
||||
logging.verbose(f"Skipped virtual package {block} in file: {path}")
|
||||
continue
|
||||
|
||||
# Add the next package and all aliases
|
||||
|
@ -480,5 +480,5 @@ def package(
|
|||
|
||||
# No provider
|
||||
if must_exist:
|
||||
raise RuntimeError("Package '" + package + "' not found in any" " APKINDEX.")
|
||||
raise RuntimeError("Package '" + package + "' not found in any APKINDEX.")
|
||||
return None
|
||||
|
|
|
@ -72,7 +72,7 @@ def type_ondev_cp(val: str) -> list[str]:
|
|||
ret = val.split(":")
|
||||
|
||||
if len(ret) != 2:
|
||||
raise argparse.ArgumentTypeError("does not have HOST_SRC:CHROOT_DEST" f" format: {val}")
|
||||
raise argparse.ArgumentTypeError(f"does not have HOST_SRC:CHROOT_DEST format: {val}")
|
||||
host_src = ret[0]
|
||||
if not os.path.exists(host_src):
|
||||
raise argparse.ArgumentTypeError(f"HOST_SRC not found: {host_src}")
|
||||
|
@ -81,7 +81,7 @@ def type_ondev_cp(val: str) -> list[str]:
|
|||
|
||||
chroot_dest = ret[1]
|
||||
if not chroot_dest.startswith("/"):
|
||||
raise argparse.ArgumentTypeError("CHROOT_DEST must start with '/':" f" {chroot_dest}")
|
||||
raise argparse.ArgumentTypeError(f"CHROOT_DEST must start with '/': {chroot_dest}")
|
||||
return ret
|
||||
|
||||
|
||||
|
@ -151,8 +151,7 @@ def arguments_install(subparser: argparse._SubParsersAction) -> None:
|
|||
)
|
||||
group.add_argument(
|
||||
"--android-recovery-zip",
|
||||
help="generate TWRP flashable zip (recommended read:"
|
||||
" https://postmarketos.org/recoveryzip)",
|
||||
help="generate TWRP flashable zip (recommended read: https://postmarketos.org/recoveryzip)",
|
||||
action="store_true",
|
||||
dest="android_recovery_zip",
|
||||
)
|
||||
|
@ -356,8 +355,7 @@ def arguments_flasher(subparser: argparse._SubParsersAction) -> argparse.Argumen
|
|||
flash_kernel.add_argument(
|
||||
"--partition",
|
||||
default=None,
|
||||
help="partition to flash the kernel to (defaults"
|
||||
" to deviceinfo_flash_*_partition_kernel)",
|
||||
help="partition to flash the kernel to (defaults to deviceinfo_flash_*_partition_kernel)",
|
||||
)
|
||||
|
||||
# Flash lk2nd
|
||||
|
@ -529,9 +527,7 @@ def arguments_qemu(subparser: argparse._SubParsersAction) -> argparse.ArgumentPa
|
|||
dest="qemu_gl",
|
||||
default=True,
|
||||
action="store_false",
|
||||
help="Avoid using GL for"
|
||||
" accelerating graphics in QEMU (use software"
|
||||
" rasterizer, slow!)",
|
||||
help="Avoid using GL for accelerating graphics in QEMU (use software rasterizer, slow!)",
|
||||
)
|
||||
ret.add_argument(
|
||||
"--video",
|
||||
|
@ -569,9 +565,7 @@ def arguments_pkgrel_bump(subparser: argparse._SubParsersAction) -> argparse.Arg
|
|||
ret.add_argument(
|
||||
"--dry",
|
||||
action="store_true",
|
||||
help="instead of modifying"
|
||||
" APKBUILDs, exit with >0 when a package would have been"
|
||||
" bumped",
|
||||
help="instead of modifying APKBUILDs, exit with >0 when a package would have been bumped",
|
||||
)
|
||||
|
||||
# Mutually exclusive: "--auto" or package names
|
||||
|
@ -1058,7 +1052,7 @@ def get_parser() -> argparse.ArgumentParser:
|
|||
"-a",
|
||||
"--all",
|
||||
action=toggle_other_boolean_flags(*zap_all_delete_args),
|
||||
help="delete everything, equivalent to: " f"--{' --'.join(zap_all_delete_args_print)}",
|
||||
help=f"delete everything, equivalent to: --{' --'.join(zap_all_delete_args_print)}",
|
||||
)
|
||||
|
||||
# Action: stats
|
||||
|
|
|
@ -102,8 +102,7 @@ def bootimg(path: Path) -> Bootimg:
|
|||
if "android bootimg" not in file_output.lower():
|
||||
if get_context().force:
|
||||
logging.warning(
|
||||
"WARNING: boot.img file seems to be invalid, but"
|
||||
" proceeding anyway (-f specified)"
|
||||
"WARNING: boot.img file seems to be invalid, but proceeding anyway (-f specified)"
|
||||
)
|
||||
else:
|
||||
logging.info(
|
||||
|
|
|
@ -31,7 +31,7 @@ def package_provider(
|
|||
|
||||
# 2. Provider with the same package name
|
||||
if pkgname in providers:
|
||||
logging.verbose(f"{pkgname}: choosing package of the same name as " "provider")
|
||||
logging.verbose(f"{pkgname}: choosing package of the same name as provider")
|
||||
return providers[pkgname]
|
||||
|
||||
# 3. Pick a package that will be installed anyway
|
||||
|
|
|
@ -212,9 +212,9 @@ class Deviceinfo:
|
|||
" let us know in the postmarketOS issues!)"
|
||||
)
|
||||
if "nonfree" in info:
|
||||
raise RuntimeError("deviceinfo_nonfree is unused. " f"Please delete it in: {path}")
|
||||
raise RuntimeError(f"deviceinfo_nonfree is unused. Please delete it in: {path}")
|
||||
if "dev_keyboard" in info:
|
||||
raise RuntimeError("deviceinfo_dev_keyboard is unused. " f"Please delete it in: {path}")
|
||||
raise RuntimeError(f"deviceinfo_dev_keyboard is unused. Please delete it in: {path}")
|
||||
if "date" in info:
|
||||
raise RuntimeError(
|
||||
"deviceinfo_date was replaced by deviceinfo_year. "
|
||||
|
@ -224,7 +224,7 @@ class Deviceinfo:
|
|||
# "codename" is required
|
||||
codename = os.path.basename(os.path.dirname(path))[7:]
|
||||
if "codename" not in info or info["codename"] != codename:
|
||||
raise RuntimeError(f"Please add 'deviceinfo_codename=\"{codename}\"' " f"to: {path}")
|
||||
raise RuntimeError(f"Please add 'deviceinfo_codename=\"{codename}\"' to: {path}")
|
||||
|
||||
# "chassis" is required
|
||||
chassis_types = pmb.config.deviceinfo_chassis_types
|
||||
|
|
|
@ -345,7 +345,5 @@ def check_file(
|
|||
"""
|
||||
arch = extract_arch(config_path)
|
||||
version = extract_version(config_path)
|
||||
logging.debug(
|
||||
f"Check kconfig: parsed arch={arch}, version={version} from " f"file: {config_path}"
|
||||
)
|
||||
logging.debug(f"Check kconfig: parsed arch={arch}, version={version} from file: {config_path}")
|
||||
return check_config(config_path, arch, version, components_list, details=details)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue