more type annotations
This commit is contained in:
parent
30fbfffb96
commit
e3bb36afac
@ -9,7 +9,7 @@ from concurrent.futures import ThreadPoolExecutor
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path, PurePath, PurePosixPath
|
||||
from subprocess import check_call
|
||||
from typing import Any, Dict, Generator, List, Sequence, TypeVar
|
||||
from typing import Any, Dict, Generator, List, Sequence, TypeVar, Tuple
|
||||
|
||||
from github.GitReleaseAsset import GitReleaseAsset
|
||||
|
||||
@ -155,7 +155,7 @@ def staging_dependencies(
|
||||
asset_path = os.path.join(repo_dir, get_asset_filename(asset))
|
||||
todo.append((asset_path, asset))
|
||||
|
||||
def fetch_item(item):
|
||||
def fetch_item(item: Tuple[str, GitReleaseAsset]) -> Tuple[str, GitReleaseAsset]:
|
||||
asset_path, asset = item
|
||||
download_asset(asset, asset_path)
|
||||
return item
|
||||
|
||||
@ -92,7 +92,7 @@ def run_build(args: Any) -> None:
|
||||
continue
|
||||
|
||||
|
||||
def add_parser(subparsers) -> None:
|
||||
def add_parser(subparsers: Any) -> None:
|
||||
sub = subparsers.add_parser("build", help="Build all packages")
|
||||
sub.add_argument("-t", "--build-types", action="store")
|
||||
sub.add_argument(
|
||||
|
||||
@ -56,7 +56,7 @@ def clean_gha_assets(args: Any) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def add_parser(subparsers) -> None:
|
||||
def add_parser(subparsers: Any) -> None:
|
||||
sub = subparsers.add_parser("clean-assets", help="Clean up GHA assets", allow_abbrev=False)
|
||||
sub.add_argument(
|
||||
"--dry-run", action="store_true", help="Only show what is going to be deleted")
|
||||
|
||||
@ -37,7 +37,7 @@ def clear_failed_state(args: Any) -> None:
|
||||
asset.delete_asset()
|
||||
|
||||
|
||||
def add_parser(subparsers) -> None:
|
||||
def add_parser(subparsers: Any) -> None:
|
||||
sub = subparsers.add_parser(
|
||||
"clear-failed", help="Clear the failed state for packages", allow_abbrev=False)
|
||||
sub.add_argument(
|
||||
|
||||
@ -2,7 +2,7 @@ import fnmatch
|
||||
import os
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
from github.GitReleaseAsset import GitReleaseAsset
|
||||
|
||||
@ -73,7 +73,7 @@ def fetch_assets(args: Any) -> None:
|
||||
asset_path = asset_dir / get_asset_filename(asset)
|
||||
to_fetch[str(asset_path)] = asset
|
||||
|
||||
def file_is_uptodate(path, asset):
|
||||
def file_is_uptodate(path: str, asset: GitReleaseAsset) -> bool:
|
||||
asset_path = Path(path)
|
||||
if not asset_path.exists():
|
||||
return False
|
||||
@ -132,7 +132,7 @@ def fetch_assets(args: Any) -> None:
|
||||
print("Pass --fetch-all to fetch all packages.")
|
||||
print("Pass --delete to clear the target directory")
|
||||
|
||||
def fetch_item(item):
|
||||
def fetch_item(item: Tuple[str, GitReleaseAsset]) -> Tuple[str, GitReleaseAsset]:
|
||||
asset_path, asset = item
|
||||
if not args.pretend:
|
||||
download_asset(asset, asset_path)
|
||||
@ -145,7 +145,7 @@ def fetch_assets(args: Any) -> None:
|
||||
print("done")
|
||||
|
||||
|
||||
def add_parser(subparsers) -> None:
|
||||
def add_parser(subparsers: Any) -> None:
|
||||
sub = subparsers.add_parser(
|
||||
"fetch-assets", help="Download all staging packages", allow_abbrev=False)
|
||||
sub.add_argument("targetdir")
|
||||
|
||||
@ -57,7 +57,7 @@ def show_build(args: Any) -> None:
|
||||
show_table("DONE", done)
|
||||
|
||||
|
||||
def add_parser(subparsers) -> None:
|
||||
def add_parser(subparsers: Any) -> None:
|
||||
sub = subparsers.add_parser(
|
||||
"show", help="Show all packages to be built", allow_abbrev=False)
|
||||
sub.add_argument(
|
||||
|
||||
@ -7,7 +7,7 @@ def run_update_status(args: Any) -> None:
|
||||
update_status(get_buildqueue_with_status(full_details=True))
|
||||
|
||||
|
||||
def add_parser(subparsers) -> None:
|
||||
def add_parser(subparsers: Any) -> None:
|
||||
sub = subparsers.add_parser(
|
||||
"update-status", help="Update the status file", allow_abbrev=False)
|
||||
sub.set_defaults(func=run_update_status)
|
||||
|
||||
@ -54,7 +54,7 @@ def upload_assets(args: Any) -> None:
|
||||
print("Done")
|
||||
|
||||
|
||||
def add_parser(subparsers) -> None:
|
||||
def add_parser(subparsers: Any) -> None:
|
||||
sub = subparsers.add_parser(
|
||||
"upload-assets", help="Upload packages", allow_abbrev=False)
|
||||
sub.add_argument("path", help="Directory to look for packages in")
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import json
|
||||
import shlex
|
||||
from typing import Any, Dict, List
|
||||
from typing import Any, Dict, List, Iterator
|
||||
import itertools
|
||||
|
||||
from .config import BuildType, Config, build_type_is_src
|
||||
@ -10,7 +10,7 @@ from .queue import (Package, PackageStatus, get_buildqueue_with_status,
|
||||
from .utils import apply_optional_deps
|
||||
|
||||
|
||||
def generate_jobs_for(build_type: BuildType, optional_deps: str, count: int):
|
||||
def generate_jobs_for(build_type: BuildType, optional_deps: str, count: int) -> Iterator[Dict[str, Any]]:
|
||||
name = build_type
|
||||
packages = " ".join(["base-devel"])
|
||||
runner = ["windows-2022"] if build_type != "clangarm64" else ["Windows", "ARM64", "autobuild"]
|
||||
@ -28,7 +28,7 @@ def generate_jobs_for(build_type: BuildType, optional_deps: str, count: int):
|
||||
}
|
||||
|
||||
|
||||
def generate_src_jobs(optional_deps: str, count: int):
|
||||
def generate_src_jobs(optional_deps: str, count: int) -> Iterator[Dict[str, Any]]:
|
||||
name = "src"
|
||||
packages = " ".join(["base-devel", "VCS"])
|
||||
runner = ["windows-2022"]
|
||||
@ -48,7 +48,7 @@ def generate_src_jobs(optional_deps: str, count: int):
|
||||
|
||||
|
||||
# from https://docs.python.org/3/library/itertools.html
|
||||
def roundrobin(*iterables):
|
||||
def roundrobin(*iterables): # type: ignore
|
||||
"roundrobin('ABC', 'D', 'EF') --> A D E B F C"
|
||||
# Recipe credited to George Sakkis
|
||||
num_active = len(iterables)
|
||||
@ -124,7 +124,7 @@ def write_build_plan(args: Any) -> None:
|
||||
write_out(jobs)
|
||||
|
||||
|
||||
def add_parser(subparsers) -> None:
|
||||
def add_parser(subparsers: Any) -> None:
|
||||
sub = subparsers.add_parser(
|
||||
"write-build-plan", help="Write a GHA build matrix setup", allow_abbrev=False)
|
||||
sub.add_argument("--optional-deps", action="store")
|
||||
|
||||
@ -253,9 +253,9 @@ def get_release(repo: Repository, name: str, create: bool = True) -> GitRelease:
|
||||
|
||||
class CachedAssets:
|
||||
|
||||
def __init__(self):
|
||||
self._assets = {}
|
||||
self._failed = {}
|
||||
def __init__(self) -> None:
|
||||
self._assets: Dict[BuildType, List[GitReleaseAsset]] = {}
|
||||
self._failed: Dict[str, List[GitReleaseAsset]] = {}
|
||||
|
||||
def get_assets(self, build_type: BuildType) -> List[GitReleaseAsset]:
|
||||
if build_type not in self._assets:
|
||||
|
||||
@ -65,7 +65,7 @@ class Package(dict):
|
||||
|
||||
def set_blocked(
|
||||
self, build_type: BuildType, status: PackageStatus,
|
||||
dep: "Package", dep_type: BuildType):
|
||||
dep: "Package", dep_type: BuildType) -> None:
|
||||
dep_details = dep.get_status_details(dep_type)
|
||||
dep_blocked = dep_details.get("blocked", {})
|
||||
details = self.get_status_details(build_type)
|
||||
@ -116,7 +116,7 @@ class Package(dict):
|
||||
build_type = Config.MSYS_SRC_ARCH
|
||||
return self._get_build(build_type)
|
||||
|
||||
def is_optional_dep(self, dep: "Package", dep_type: BuildType):
|
||||
def is_optional_dep(self, dep: "Package", dep_type: BuildType) -> bool:
|
||||
# Some deps are manually marked as optional to break cycles.
|
||||
# This requires them to be in the main repo though, otherwise the cycle has to
|
||||
# be fixed manually.
|
||||
|
||||
@ -19,7 +19,7 @@ def requests_cache_disabled() -> Any:
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def get_requests_session(nocache=False) -> requests.Session:
|
||||
def get_requests_session(nocache: bool = False) -> requests.Session:
|
||||
adapter = HTTPAdapter(max_retries=REQUESTS_RETRY)
|
||||
if nocache:
|
||||
with requests_cache_disabled():
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
# type: ignore
|
||||
|
||||
from msys2_autobuild.utils import parse_optional_deps
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user