chore: add PyLint and fix most issues (#999)
* chore: add PyLint and fix most issues * fix: minor fixes after first push * chore: remove reference to old toml lib * chore: minor options cleanup * ci: only fail with many pylint issues, annotate in GHA * refactor: address review * ci: force nox to report in CI * refactor: use map instead of if chain * refactor: simpler shell_with_arch * refactor: even simpler shell_with_arch * Restore if...elif...else blocks where guard-style is not intended Co-authored-by: Joe Rickerby <joerick@mac.com>
This commit is contained in:
co-authored by
Joe Rickerby
parent
6d120e7a6b
commit
d6dc3b7cd9
+8
-12
@@ -1,3 +1,4 @@
|
||||
import functools
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
@@ -5,7 +6,7 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, NamedTuple, Sequence, Set, Tuple, cast
|
||||
from typing import Dict, List, NamedTuple, Sequence, Set, Tuple, cast
|
||||
|
||||
from filelock import FileLock
|
||||
|
||||
@@ -108,7 +109,7 @@ def install_cpython(tmp: Path, version: str, url: str) -> Path:
|
||||
return installation_path / "bin" / "python3"
|
||||
|
||||
|
||||
def install_pypy(tmp: Path, version: str, url: str) -> Path:
|
||||
def install_pypy(tmp: Path, url: str) -> Path:
|
||||
pypy_tar_bz2 = url.rsplit("/", 1)[-1]
|
||||
extension = ".tar.bz2"
|
||||
assert pypy_tar_bz2.endswith(extension)
|
||||
@@ -136,7 +137,7 @@ def setup_python(
|
||||
if implementation_id.startswith("cp"):
|
||||
base_python = install_cpython(tmp, python_configuration.version, python_configuration.url)
|
||||
elif implementation_id.startswith("pp"):
|
||||
base_python = install_pypy(tmp, python_configuration.version, python_configuration.url)
|
||||
base_python = install_pypy(tmp, python_configuration.url)
|
||||
else:
|
||||
raise ValueError("Unknown Python implementation")
|
||||
assert base_python.exists()
|
||||
@@ -460,17 +461,12 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
# rosetta2 will provide the emulation with just the arch prefix.
|
||||
arch_prefix = ["arch", "-x86_64"]
|
||||
else:
|
||||
raise RuntimeError(
|
||||
"don't know how to emulate {testing_arch} on {machine_arch}"
|
||||
)
|
||||
msg = f"don't know how to emulate {testing_arch} on {machine_arch}"
|
||||
raise RuntimeError(msg)
|
||||
|
||||
# define a custom 'call' function that adds the arch prefix each time
|
||||
def call_with_arch(*args: PathOrStr, **kwargs: Any) -> None:
|
||||
call(*arch_prefix, *args, **kwargs)
|
||||
|
||||
def shell_with_arch(command: str, **kwargs: Any) -> None:
|
||||
command = " ".join(arch_prefix) + " " + command
|
||||
shell(command, **kwargs)
|
||||
call_with_arch = functools.partial(call, *arch_prefix)
|
||||
shell_with_arch = functools.partial(shell, *arch_prefix)
|
||||
|
||||
# Use --no-download to ensure determinism by using seed libraries
|
||||
# built into virtualenv
|
||||
|
||||
Reference in New Issue
Block a user