pmb: Add more type hints (MR 2513)

And fix some consequential type errors.

[ci:skip-build]: already built successfully in CI
This commit is contained in:
Newbyte 2024-12-19 18:49:49 +01:00
parent c8194302fc
commit 0925b3e425
No known key found for this signature in database
GPG key ID: ACD854892B38D898
12 changed files with 69 additions and 19 deletions

View file

@ -1,6 +1,8 @@
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
from typing import overload, Literal
from pmb.core.arch import Arch
from pmb.helpers import logging
from pmb.types import Apkbuild
@ -126,7 +128,27 @@ def generate_output_format(arch: Arch, pkgnames: list[str]) -> list[Apkbuild]:
return ret
def generate(arch, overview, pkgname=None, built=False):
@overload
def generate(
arch: Arch, overview: Literal[False], pkgname: str | None = ..., built: bool = ...
) -> list[Apkbuild]: ...
@overload
def generate(
arch: Arch, overview: Literal[True], pkgname: str | None = ..., built: bool = ...
) -> list[str]: ...
@overload
def generate(
arch: Arch, overview: bool, pkgname: str | None = ..., built: bool = ...
) -> list[Apkbuild] | list[str]: ...
def generate(
arch: Arch, overview: bool, pkgname: str | None = None, built: bool = False
) -> list[Apkbuild] | list[str]:
"""Get packages that need to be built, with all their dependencies.
:param arch: architecture (e.g. "armhf")