mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-25 02:57:14 +08:00
Install pyright from PyPI (#11575)
This commit is contained in:
@@ -25,7 +25,7 @@ extension_descriptions = {".pyi": "stub", ".py": ".py"}
|
||||
|
||||
# These type checkers and linters must have exact versions in the requirements file to ensure
|
||||
# consistent CI runs.
|
||||
linters = {"black", "flake8", "flake8-noqa", "flake8-pyi", "ruff", "mypy", "pytype"}
|
||||
linters = {"black", "flake8", "flake8-noqa", "flake8-pyi", "mypy", "pyright", "pytype", "ruff"}
|
||||
|
||||
|
||||
def assert_consistent_filetypes(
|
||||
|
||||
@@ -6,7 +6,7 @@ import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import tomli
|
||||
from utils import parse_requirements, print_command
|
||||
|
||||
_WELL_KNOWN_FILE = Path("tests", "pyright_test.py")
|
||||
|
||||
@@ -29,12 +29,16 @@ def main() -> None:
|
||||
print("error running npx; is Node.js installed?", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
with open("pyproject.toml", "rb") as config:
|
||||
pyright_version: str = tomli.load(config)["tool"]["typeshed"]["pyright_version"]
|
||||
req = parse_requirements()["pyright"]
|
||||
spec = str(req.specifier)
|
||||
pyright_version = spec[2:]
|
||||
|
||||
# TODO: We're currently using npx to run pyright, instead of calling the
|
||||
# version installed into the virtual environment, due to failures on some
|
||||
# platforms. https://github.com/python/typeshed/issues/11614
|
||||
os.environ["PYRIGHT_PYTHON_FORCE_VERSION"] = pyright_version
|
||||
command = [npx, f"pyright@{pyright_version}"] + sys.argv[1:]
|
||||
print("Running:", " ".join(command))
|
||||
print_command(command)
|
||||
|
||||
ret = subprocess.run(command).returncode
|
||||
sys.exit(ret)
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from collections.abc import Mapping
|
||||
from collections.abc import Iterable, Mapping
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from typing import Any, Final, NamedTuple
|
||||
@@ -38,6 +38,12 @@ def strip_comments(text: str) -> str:
|
||||
# ====================================================================
|
||||
|
||||
|
||||
def print_command(cmd: str | Iterable[str]) -> None:
|
||||
if not isinstance(cmd, str):
|
||||
cmd = " ".join(cmd)
|
||||
print(colored(f"Running: {cmd}", "blue"))
|
||||
|
||||
|
||||
def print_error(error: str, end: str = "\n", fix_path: tuple[str, str] = ("", "")) -> None:
|
||||
error_split = error.split("\n")
|
||||
old, new = fix_path
|
||||
|
||||
Reference in New Issue
Block a user