aedi: fix missing and erroneous type hints

This commit is contained in:
alexey.lysiuk 2021-08-04 09:38:54 +03:00
parent c6e40329e6
commit 5dc10de290
3 changed files with 9 additions and 7 deletions

View file

@ -40,7 +40,7 @@ class Builder(object):
state.xcode = arguments.xcode
state.verbose = arguments.verbose
self._platforms = []
self._platforms: typing.List[TargetPlatform] = []
self._populate_platforms(arguments)
state.platform = self._platforms[0]
@ -193,7 +193,7 @@ class Builder(object):
# Merge executable and library files
dst_file = dst_path / src.name
args = ['lipo']
args: typing.List[typing.Union[str, Path]] = ['lipo']
args += src_sub_paths
args += ['-create', '-output', dst_file]
subprocess.check_call(args)

View file

@ -22,6 +22,7 @@ import os
from pathlib import Path
import shutil
import subprocess
import typing
import urllib.request
@ -80,7 +81,7 @@ class BuildState:
args = ('git', 'checkout', '-b', branch, 'origin/' + branch)
subprocess.run(args, cwd=self.source, check=True)
def download_source(self, url: str, checksum: str, patches: [tuple, list, str] = None):
def download_source(self, url: str, checksum: str, patches: typing.Union[tuple, list, str] = None):
if self.external_source:
return
@ -105,7 +106,7 @@ class BuildState:
self.source = extract_path
self.build_path = self.build_path / first_path_component
def _read_source_package(self, url: str) -> (bytes, Path):
def _read_source_package(self, url: str) -> typing.Tuple[bytes, Path]:
filename = url.rsplit(os.sep, 1)[1]
filepath = self.source / filename
@ -140,7 +141,7 @@ class BuildState:
filepath.unlink()
raise Exception(f'Checksum of {filepath} does not match, expected: {checksum}, actual: {file_checksum}')
def _unpack_source_package(self, filepath: Path) -> (str, Path):
def _unpack_source_package(self, filepath: Path) -> typing.Tuple[str, Path]:
filepaths = subprocess.check_output(['tar', '-tf', filepath]).decode("utf-8")
filepaths = filepaths.split('\n')
first_path_component = None
@ -186,5 +187,5 @@ class BuildState:
return result.decode('utf-8').rstrip('\n')
def has_source_file(self, path: [str, Path]):
def has_source_file(self, path: typing.Union[str, Path]):
return (self.source / path).exists()

View file

@ -21,6 +21,7 @@ from distutils.version import StrictVersion
import os
from pathlib import Path
import shutil
import typing
# Minimum OS versions
@ -51,7 +52,7 @@ class CommandLineOptions(dict):
class TargetPlatform:
def __init__(self, architecture: str, host: str, os_version: [str, StrictVersion],
def __init__(self, architecture: str, host: str, os_version: typing.Union[str, StrictVersion],
sdk_path: Path, prefix_path: Path):
self.architecture = architecture
self.host = host