Use variable annotations instead of workarounds
This commit is contained in:
@@ -134,7 +134,7 @@ def main() -> None:
|
|||||||
|
|
||||||
dependency_versions = get_option_from_environment('CIBW_DEPENDENCY_VERSIONS', platform=platform, default='pinned')
|
dependency_versions = get_option_from_environment('CIBW_DEPENDENCY_VERSIONS', platform=platform, default='pinned')
|
||||||
if dependency_versions == 'pinned':
|
if dependency_versions == 'pinned':
|
||||||
dependency_constraints = DependencyConstraints.with_defaults() # type: Optional[DependencyConstraints]
|
dependency_constraints: Optional[DependencyConstraints] = DependencyConstraints.with_defaults()
|
||||||
elif dependency_versions == 'latest':
|
elif dependency_versions == 'latest':
|
||||||
dependency_constraints = None
|
dependency_constraints = None
|
||||||
else:
|
else:
|
||||||
@@ -169,7 +169,7 @@ def main() -> None:
|
|||||||
print_build_identifiers(platform, build_selector)
|
print_build_identifiers(platform, build_selector)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
manylinux_images = None # type: Optional[Dict[str, str]]
|
manylinux_images: Optional[Dict[str, str]] = None
|
||||||
if platform == 'linux':
|
if platform == 'linux':
|
||||||
pinned_docker_images_file = os.path.join(
|
pinned_docker_images_file = os.path.join(
|
||||||
os.path.dirname(__file__), 'resources', 'pinned_docker_images.cfg'
|
os.path.dirname(__file__), 'resources', 'pinned_docker_images.cfg'
|
||||||
@@ -287,14 +287,13 @@ def print_preamble(platform: str, build_options: BuildOptions) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def print_build_identifiers(platform: str, build_selector: BuildSelector) -> None:
|
def print_build_identifiers(platform: str, build_selector: BuildSelector) -> None:
|
||||||
|
python_configurations: List[Any] = []
|
||||||
if platform == 'linux':
|
if platform == 'linux':
|
||||||
python_configurations = cibuildwheel.linux.get_python_configurations(build_selector) # type: List[Any]
|
python_configurations = cibuildwheel.linux.get_python_configurations(build_selector)
|
||||||
elif platform == 'windows':
|
elif platform == 'windows':
|
||||||
python_configurations = cibuildwheel.windows.get_python_configurations(build_selector)
|
python_configurations = cibuildwheel.windows.get_python_configurations(build_selector)
|
||||||
elif platform == 'macos':
|
elif platform == 'macos':
|
||||||
python_configurations = cibuildwheel.macos.get_python_configurations(build_selector)
|
python_configurations = cibuildwheel.macos.get_python_configurations(build_selector)
|
||||||
else:
|
|
||||||
python_configurations = []
|
|
||||||
|
|
||||||
for config in python_configurations:
|
for config in python_configurations:
|
||||||
print(config.identifier)
|
print(config.identifier)
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ from typing import Dict, List, NamedTuple, Optional
|
|||||||
|
|
||||||
import bashlex # type: ignore
|
import bashlex # type: ignore
|
||||||
|
|
||||||
NodeExecutionContext = NamedTuple('NodeExecutionContext',
|
|
||||||
[('environment', Dict[str, str]),
|
class NodeExecutionContext(NamedTuple):
|
||||||
('input', str)])
|
environment: Dict[str, str]
|
||||||
|
input: str
|
||||||
|
|
||||||
|
|
||||||
def evaluate(value: str, environment: Dict[str, str]) -> str:
|
def evaluate(value: str, environment: Dict[str, str]) -> str:
|
||||||
@@ -44,7 +45,7 @@ def evaluate_word_node(node: bashlex.ast.node, context: NodeExecutionContext) ->
|
|||||||
word_start = node.pos[0]
|
word_start = node.pos[0]
|
||||||
word_end = node.pos[1]
|
word_end = node.pos[1]
|
||||||
word_string = context.input[word_start:word_end]
|
word_string = context.input[word_start:word_end]
|
||||||
letters = list(word_string) # type: List[Optional[str]]
|
letters: List[Optional[str]] = list(word_string)
|
||||||
|
|
||||||
for part in node.parts:
|
for part in node.parts:
|
||||||
part_start = part.pos[0] - word_start
|
part_start = part.pos[0] - word_start
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ def matches_platform(identifier: str) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
PythonConfiguration = NamedTuple('PythonConfiguration', [('version', str), ('identifier', str), ('path', str)])
|
class PythonConfiguration(NamedTuple):
|
||||||
|
version: str
|
||||||
|
identifier: str
|
||||||
|
path: str
|
||||||
|
|
||||||
|
|
||||||
def get_python_configurations(build_selector: Callable[[str], bool]) -> List[PythonConfiguration]:
|
def get_python_configurations(build_selector: Callable[[str], bool]) -> List[PythonConfiguration]:
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ def call(args: Union[str, List[str]], env: Optional[Dict[str, str]] = None, cwd:
|
|||||||
return subprocess.check_call(args, env=env, cwd=cwd, shell=shell)
|
return subprocess.check_call(args, env=env, cwd=cwd, shell=shell)
|
||||||
|
|
||||||
|
|
||||||
PythonConfiguration = NamedTuple('PythonConfiguration', [('version', str), ('identifier', str), ('url', str)])
|
class PythonConfiguration(NamedTuple):
|
||||||
|
version: str
|
||||||
|
identifier: str
|
||||||
|
url: str
|
||||||
|
|
||||||
|
|
||||||
def get_python_configurations(build_selector: Callable[[str], bool]) -> List[PythonConfiguration]:
|
def get_python_configurations(build_selector: Callable[[str], bool]) -> List[PythonConfiguration]:
|
||||||
|
|||||||
+14
-19
@@ -110,26 +110,21 @@ class DependencyConstraints:
|
|||||||
return self.base_file_path
|
return self.base_file_path
|
||||||
|
|
||||||
|
|
||||||
BuildOptions = NamedTuple("BuildOptions", [
|
class BuildOptions(NamedTuple):
|
||||||
("package_dir", str),
|
package_dir: str
|
||||||
("output_dir", str),
|
output_dir: str
|
||||||
("test_command", Optional[str]),
|
test_command: Optional[str]
|
||||||
("test_requires", List[str]),
|
test_requires: List[str]
|
||||||
("test_extras", str),
|
test_extras: str
|
||||||
("before_build", Optional[str]),
|
before_build: Optional[str]
|
||||||
("build_verbosity", int),
|
build_verbosity: int
|
||||||
("build_selector", BuildSelector),
|
build_selector: BuildSelector
|
||||||
("repair_command", str),
|
repair_command: str
|
||||||
("environment", ParsedEnvironment),
|
environment: ParsedEnvironment
|
||||||
("before_test", str),
|
before_test: str
|
||||||
("dependency_constraints", Optional[DependencyConstraints]),
|
dependency_constraints: Optional[DependencyConstraints]
|
||||||
("manylinux_images", Optional[Dict[str, str]]),
|
manylinux_images: Optional[Dict[str, str]]
|
||||||
])
|
|
||||||
|
|
||||||
"""
|
|
||||||
Replace this definition with a class-style NamedTuple in the
|
|
||||||
PEP526 style when Python 3.5 host support is dropped
|
|
||||||
"""
|
|
||||||
|
|
||||||
resources_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'resources'))
|
resources_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'resources'))
|
||||||
get_pip_script = os.path.join(resources_dir, 'get-pip.py')
|
get_pip_script = os.path.join(resources_dir, 'get-pip.py')
|
||||||
|
|||||||
@@ -34,7 +34,11 @@ def get_nuget_args(version: str, arch: str) -> List[str]:
|
|||||||
return [python_name, '-Version', version, '-OutputDirectory', 'C:\\cibw\\python']
|
return [python_name, '-Version', version, '-OutputDirectory', 'C:\\cibw\\python']
|
||||||
|
|
||||||
|
|
||||||
PythonConfiguration = NamedTuple('PythonConfiguration', [('version', str), ('arch', str), ('identifier', str), ('url', Optional[str])])
|
class PythonConfiguration(NamedTuple):
|
||||||
|
version: str
|
||||||
|
arch: str
|
||||||
|
identifier: str
|
||||||
|
url: Optional[str]
|
||||||
|
|
||||||
|
|
||||||
def get_python_configurations(build_selector: Callable[[str], bool]) -> List[PythonConfiguration]:
|
def get_python_configurations(build_selector: Callable[[str], bool]) -> List[PythonConfiguration]:
|
||||||
|
|||||||
Reference in New Issue
Block a user