mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 14:01:55 +08:00
I recently published https://github.com/marketplace/actions/run-pyright, which wraps pyright and uses GHA magic to leave diagnostics on commits / PRs (like https://github.com/jakebailey/pyright-action-test/pull/1/files), plus a faster startup time thanks to GHA tool caching and piggy backing off of the `node` install used in GHA itself (so no `setup-node` needed). This PR switches to that action and leaves a comment noting that the version number is pinned in two places. This action is a prototype, but I'm pretty confident in it so far.
38 lines
932 B
Python
Executable File
38 lines
932 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
_PYRIGHT_VERSION = "1.1.136" # Must match tests.yml.
|
|
_WELL_KNOWN_FILE = Path("tests", "pyright_test.py")
|
|
|
|
|
|
def main() -> 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"])
|
|
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()
|