treewide: adopt pathlib.Path and type hinting (MR 2252)

With the new chroot type, we can now write fancy paths in the pythonic
way. Convert most of the codebase over, as well as adding various other
type hints.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-04-04 06:14:14 +02:00 committed by Oliver Smith
parent 00383bf354
commit 31cc898dd5
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
64 changed files with 513 additions and 385 deletions

View file

@ -423,8 +423,7 @@ def ask_for_device(args: PmbArgs):
device = f"{vendor}-{codename}"
device_path = pmb.helpers.devices.find_path(args, device, 'deviceinfo')
device_exists = device_path is not None
if not device_exists:
if device_path is None:
if device == args.device:
raise RuntimeError(
"This device does not exist anymore, check"
@ -449,7 +448,7 @@ def ask_for_device(args: PmbArgs):
break
kernel = ask_for_device_kernel(args, device)
return (device, device_exists, kernel)
return (device, device_path is not None, kernel)
def ask_for_additional_options(args: PmbArgs, cfg):
@ -739,7 +738,7 @@ def frontend(args: PmbArgs):
# Zap existing chroots
if (work_exists and device_exists and
len(glob.glob(pmb.config.work / "chroot_*")) and
len(list(Chroot.iter_patterns())) and
pmb.helpers.cli.confirm(
args, "Zap existing chroots to apply configuration?",
default=True)):