Skip to content

Run pyright on matrix of platforms and python versions #5072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,18 @@ jobs:
pyright:
name: Run pyright against the stubs
runs-on: ubuntu-latest
strategy:
matrix:
python-platform: ["Linux", "Windows", "Darwin"]
python-version: [3.6, 3.7, 3.8, 3.9]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- run: ./tests/pyright_test.py
- run: ./tests/pyright_test.py --pythonplatform ${{ matrix.python-platform }} --pythonversion ${{ matrix.python-version }}

stubtest:
name: Check stdlib with stubtest
Expand Down
1 change: 0 additions & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"stubs/waitress",
"stubs/Werkzeug"
],
"pythonVersion": "3.9",
"typeCheckingMode": "basic",
"strictListInference": true,
"strictDictionaryInference": true,
Expand Down
25 changes: 16 additions & 9 deletions tests/pyright_test.py
Original file line number Diff line number Diff line change
@@ -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", "[email protected]", "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()