distro: fix type annotations to please mypy

This commit is contained in:
InsanePrawn 2022-02-18 03:30:21 +01:00
parent d13392b2b8
commit a7da033845
3 changed files with 11 additions and 6 deletions

View file

@ -1,3 +1,5 @@
from typing import Optional
from constants import ARCHES, BASE_DISTROS, REPOSITORIES, KUPFER_HTTPS, CHROOT_PATHS
from generator import generate_pacman_conf_body
from config import config
@ -57,8 +59,7 @@ def get_kupfer_https(arch: str) -> Distro:
return get_kupfer(arch, KUPFER_HTTPS)
def get_kupfer_local(arch: str = None, in_chroot: bool = True) -> Distro:
if not arch:
arch = config.runtime['arch']
def get_kupfer_local(arch: Optional[str] = None, in_chroot: bool = True) -> Distro:
arch = arch or config.runtime['arch']
dir = CHROOT_PATHS['packages'] if in_chroot else config.get_path('packages')
return get_kupfer(arch, f"file://{dir}/$arch/$repo")

View file

@ -1,8 +1,11 @@
from typing import Optional
class PackageInfo:
name: str
version: str
filename: str
resolved_url: str
resolved_url: Optional[str]
def __init__(
self,
@ -19,6 +22,7 @@ class PackageInfo:
def __repr__(self):
return f'{self.name}@{self.version}'
@staticmethod
def parse_desc(desc_str: str, resolved_url=None):
"""Parses a desc file, returning a PackageInfo"""