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

@ -2,7 +2,7 @@ import atexit
import logging import logging
import os import os
import subprocess import subprocess
from typing import Protocol from typing import Protocol, Union
from shlex import quote as shell_quote from shlex import quote as shell_quote
from config import config from config import config
@ -195,7 +195,7 @@ class Chroot(AbstractChroot):
self.active = False self.active = False
def run_cmd(self, def run_cmd(self,
script: str, script: Union[str, list[str]],
inner_env: dict[str, str] = {}, inner_env: dict[str, str] = {},
outer_env: dict[str, str] = os.environ.copy() | {'QEMU_LD_PREFIX': '/usr/aarch64-linux-gnu'}, outer_env: dict[str, str] = os.environ.copy() | {'QEMU_LD_PREFIX': '/usr/aarch64-linux-gnu'},
attach_tty: bool = False, attach_tty: bool = False,

View file

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

View file

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