diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3a1c32ac7187..44f2c756c886 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -110,27 +110,31 @@ jobs: python-platform: ["Linux", "Windows", "Darwin"] python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] fail-fast: false - env: - PYRIGHT_VERSION: 1.1.278 # Must match pyright_test.py. steps: - uses: actions/checkout@v3 + - name: Get pyright version + uses: SebRollen/toml-action@v1.0.2 + id: pyright_version + with: + file: 'pyproject.toml' + field: 'tool.typeshed.pyright_version' - uses: jakebailey/pyright-action@v1 with: - version: ${{ env.PYRIGHT_VERSION }} + version: ${{ steps.pyright_version.outputs.value }} python-platform: ${{ matrix.python-platform }} python-version: ${{ matrix.python-version }} no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy. project: ./pyrightconfig.stricter.json - uses: jakebailey/pyright-action@v1 with: - version: ${{ env.PYRIGHT_VERSION }} + version: ${{ steps.pyright_version.outputs.value }} python-platform: ${{ matrix.python-platform }} python-version: ${{ matrix.python-version }} no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy. project: ./pyrightconfig.testcases.json - uses: jakebailey/pyright-action@v1 with: - version: ${{ env.PYRIGHT_VERSION }} + version: ${{ steps.pyright_version.outputs.value }} python-platform: ${{ matrix.python-platform }} python-version: ${{ matrix.python-version }} no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy. diff --git a/pyproject.toml b/pyproject.toml index f420aa5cf335..723784db5849 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,3 +59,6 @@ extra_standard_library = [ [tool.pycln] all = true disable_all_dunder_policy = true + +[tool.typeshed] +pyright_version = "1.1.278" diff --git a/tests/pyright_test.py b/tests/pyright_test.py index c4ffe7ab1c5f..521beebd467e 100755 --- a/tests/pyright_test.py +++ b/tests/pyright_test.py @@ -6,7 +6,8 @@ import sys from pathlib import Path -_PYRIGHT_VERSION = "1.1.278" # Must match .github/workflows/tests.yml. +import tomli + _WELL_KNOWN_FILE = Path("tests", "pyright_test.py") @@ -28,8 +29,11 @@ def main() -> None: print("error running npx; is Node.js installed?", file=sys.stderr) sys.exit(1) - os.environ["PYRIGHT_PYTHON_FORCE_VERSION"] = _PYRIGHT_VERSION - command = [npx, f"pyright@{_PYRIGHT_VERSION}"] + sys.argv[1:] + with open("pyproject.toml", "rb") as config: + pyright_version: str = tomli.load(config)["tool"]["typeshed"]["pyright_version"] + + os.environ["PYRIGHT_PYTHON_FORCE_VERSION"] = pyright_version + command = [npx, f"pyright@{pyright_version}"] + sys.argv[1:] print("Running:", " ".join(command)) ret = subprocess.run(command).returncode