Fixing some review remarks

This commit is contained in:
Yannick Jadoul
2020-05-06 23:57:33 +02:00
parent 575e229514
commit 891e2dd6aa
4 changed files with 11 additions and 14 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ jobs:
- PYTHON=C:\\Python36\\python - PYTHON=C:\\Python36\\python
- &linux_s390x_36 - &linux_s390x_36
name: Linux | s390x | Python 365 name: Linux | s390x | Python 3.6
language: python language: python
python: 3.6 python: 3.6
services: docker services: docker
+4 -4
View File
@@ -1,7 +1,7 @@
import shlex import shlex
import subprocess import subprocess
from typing import Dict, List, NamedTuple, Optional from typing import Dict, NamedTuple
import bashlex # type: ignore import bashlex # type: ignore
@@ -45,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[Optional[str]] = list(word_string) letters = 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
@@ -53,12 +53,12 @@ def evaluate_word_node(node: bashlex.ast.node, context: NodeExecutionContext) ->
# Set all the characters in the part to None # Set all the characters in the part to None
for i in range(part_start, part_end): for i in range(part_start, part_end):
letters[i] = None letters[i] = ''
letters[part_start] = evaluate_node(part, context=context) letters[part_start] = evaluate_node(part, context=context)
# remove the None letters and concat # remove the None letters and concat
value = ''.join(l for l in letters if l is not None) value = ''.join(letters)
# apply bash-like quotes/whitespace treatment # apply bash-like quotes/whitespace treatment
return ' '.join(word.strip() for word in shlex.split(value)) return ' '.join(word.strip() for word in shlex.split(value))
+4 -7
View File
@@ -3,7 +3,7 @@ import urllib.request
from fnmatch import fnmatch from fnmatch import fnmatch
from time import sleep from time import sleep
from typing import Dict, List, NamedTuple, Optional, Type, TypeVar from typing import Dict, List, NamedTuple, Optional
from .environment import ParsedEnvironment from .environment import ParsedEnvironment
@@ -82,17 +82,14 @@ def download(url: str, dest: str) -> None:
response.close() response.close()
DependencyConstraints_T = TypeVar('DependencyConstraints_T', bound='DependencyConstraints')
class DependencyConstraints: class DependencyConstraints:
def __init__(self, base_file_path: str): def __init__(self, base_file_path: str):
assert os.path.exists(base_file_path) assert os.path.exists(base_file_path)
self.base_file_path = os.path.abspath(base_file_path) self.base_file_path = os.path.abspath(base_file_path)
@classmethod @staticmethod
def with_defaults(cls: Type[DependencyConstraints_T]) -> DependencyConstraints_T: def with_defaults() -> 'DependencyConstraints':
return cls( return DependencyConstraints(
base_file_path=os.path.join(os.path.dirname(__file__), 'resources', 'constraints.txt') base_file_path=os.path.join(os.path.dirname(__file__), 'resources', 'constraints.txt')
) )
+2 -2
View File
@@ -82,9 +82,8 @@ def install_cpython(version: str, arch: str, nuget: str) -> str:
return installation_path return installation_path
def install_pypy(version: str, arch: str, url: Optional[str]) -> str: def install_pypy(version: str, arch: str, url: str) -> str:
assert arch == '32' assert arch == '32'
assert url is not None
# Inside the PyPy zip file is a directory with the same name # Inside the PyPy zip file is a directory with the same name
zip_filename = url.rsplit('/', 1)[-1] zip_filename = url.rsplit('/', 1)[-1]
installation_path = os.path.join('C:\\cibw', os.path.splitext(zip_filename)[0]) installation_path = os.path.join('C:\\cibw', os.path.splitext(zip_filename)[0])
@@ -106,6 +105,7 @@ def setup_python(python_configuration: PythonConfiguration, dependency_constrain
if python_configuration.identifier.startswith('cp'): if python_configuration.identifier.startswith('cp'):
installation_path = install_cpython(python_configuration.version, python_configuration.arch, nuget) installation_path = install_cpython(python_configuration.version, python_configuration.arch, nuget)
elif python_configuration.identifier.startswith('pp'): elif python_configuration.identifier.startswith('pp'):
assert python_configuration.url is not None
installation_path = install_pypy(python_configuration.version, python_configuration.arch, python_configuration.url) installation_path = install_pypy(python_configuration.version, python_configuration.arch, python_configuration.url)
else: else:
raise ValueError("Unknown Python implementation") raise ValueError("Unknown Python implementation")