Run pyright on matrix of platforms and python versions (#5072)

* Run pyright on matrix of platforms and python versions

* Drop 3.10 from matrix, as it fails
This commit is contained in:
Jake Bailey
2021-02-25 16:24:32 -08:00
committed by GitHub
parent 4b4ced5fa0
commit 0fa7e73027
3 changed files with 22 additions and 11 deletions

View File

@@ -1,30 +1,37 @@
#!/usr/bin/env python3
import shutil
import subprocess
import sys
from pathlib import Path
_PYRIGHT_VERSION = "1.1.115"
_WELL_KNOWN_FILE = Path("tests", "pyright_test.py")
_PYRIGHT_COMMAND = ["npx", "-p", "pyright@1.1.114", "pyright"]
def main() -> None:
assert_npm_is_installed()
ret = subprocess.run(_PYRIGHT_COMMAND).returncode
sys.exit(ret)
def assert_npm_is_installed() -> None:
if not _WELL_KNOWN_FILE.exists():
print("pyright_test.py must be run from the typeshed root directory", file=sys.stderr)
sys.exit(1)
# subprocess.run on Windows does not look in PATH.
npx = shutil.which("npx")
if npx is None:
print("error finding npx; is Node.js installed?", file=sys.stderr)
sys.exit(1)
try:
subprocess.run(["npx", "--version"])
subprocess.run([npx, "--version"])
except OSError:
print("error running npx; is Node.js installed?", file=sys.stderr)
sys.exit(1)
command = [npx, "-p", "pyright@" + _PYRIGHT_VERSION, "pyright"] + sys.argv[1:]
ret = subprocess.run(command).returncode
sys.exit(ret)
if __name__ == "__main__":
main()