pmb: Add lots of type hints (MR 2464)

This commit is contained in:
Newbyte 2024-10-29 23:06:59 +01:00
parent d05d57b37e
commit 225d8b30a0
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
71 changed files with 566 additions and 325 deletions

View file

@ -10,7 +10,7 @@ import pmb.helpers.run
import pmb.helpers.pmaports
def replace(path: Path, old: str, new: str):
def replace(path: Path, old: str, new: str) -> None:
text = ""
with path.open("r", encoding="utf-8") as handle:
text = handle.read()
@ -21,7 +21,9 @@ def replace(path: Path, old: str, new: str):
handle.write(text)
def replace_apkbuild(args: PmbArgs, pkgname, key, new, in_quotes=False):
def replace_apkbuild(
args: PmbArgs, pkgname: str, key: str, new: int | str, in_quotes: bool = False
) -> None:
"""Replace one key=value line in an APKBUILD and verify it afterwards.
:param pkgname: package name, e.g. "hello-world"
@ -90,7 +92,7 @@ def is_older_than(path, seconds):
return lastmod + seconds < time.time()
def symlink(file: Path, link: Path):
def symlink(file: Path, link: Path) -> None:
"""Check if the symlink is already present, otherwise create it."""
if os.path.exists(link):
if os.path.islink(link) and os.path.realpath(os.readlink(link)) == os.path.realpath(file):