From ff7bace8e7d53c3780e15371dd290d2144365591 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 29 Nov 2022 02:30:05 -0500 Subject: [PATCH 1/3] Deduplicate pyright version --- .github/workflows/tests.yml | 11 ++++++----- tests/PYRIGHT_VERSION.txt | 1 + tests/pyright_test.py | 8 +++++--- 3 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 tests/PYRIGHT_VERSION.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3a1c32ac7187..32ed255fbb60 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -110,27 +110,28 @@ 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 + id: get-version + run: echo "::set-output name=PYRIGHT_VERSION::$( 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("tests/PYRIGHT_VERSION.txt", "r") as file: + PYRIGHT_VERSION = file.readline() + + 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 From ef9cd7f6f2b4fbc2c5440c52e9f4f16d966c9424 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 29 Nov 2022 02:47:07 -0500 Subject: [PATCH 2/3] set-output is deprecated --- .github/workflows/tests.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 32ed255fbb60..c61833c789f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -113,25 +113,24 @@ jobs: steps: - uses: actions/checkout@v3 - name: Get pyright version - id: get-version - run: echo "::set-output name=PYRIGHT_VERSION::$(> $GITHUB_ENV - uses: jakebailey/pyright-action@v1 with: - version: ${{ steps.get-version.outputs.PYRIGHT_VERSION }} + version: ${{ env.PYRIGHT_VERSION }} 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: ${{ steps.get-version.outputs.PYRIGHT_VERSION }} + version: ${{ env.PYRIGHT_VERSION }} 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: ${{ steps.get-version.outputs.PYRIGHT_VERSION }} + version: ${{ env.PYRIGHT_VERSION }} 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. From 35312d4a1ece592cfe91de7192b13062cc5f4486 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 29 Nov 2022 14:34:45 -0500 Subject: [PATCH 3/3] Store pyright version in pyproject.toml Co-authored-by: Alex Waygood --- .github/workflows/tests.yml | 12 ++++++++---- pyproject.toml | 3 +++ tests/PYRIGHT_VERSION.txt | 1 - tests/pyright_test.py | 10 ++++++---- 4 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 tests/PYRIGHT_VERSION.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c61833c789f2..44f2c756c886 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -113,24 +113,28 @@ jobs: steps: - uses: actions/checkout@v3 - name: Get pyright version - run: echo "PYRIGHT_VERSION=$(> $GITHUB_ENV + 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_VERSION.txt b/tests/PYRIGHT_VERSION.txt deleted file mode 100644 index 6d754ac3bd7d..000000000000 --- a/tests/PYRIGHT_VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -1.1.278 \ No newline at end of file diff --git a/tests/pyright_test.py b/tests/pyright_test.py index 8680d08671f3..521beebd467e 100755 --- a/tests/pyright_test.py +++ b/tests/pyright_test.py @@ -6,6 +6,8 @@ import sys from pathlib import Path +import tomli + _WELL_KNOWN_FILE = Path("tests", "pyright_test.py") @@ -27,11 +29,11 @@ def main() -> None: print("error running npx; is Node.js installed?", file=sys.stderr) sys.exit(1) - with open("tests/PYRIGHT_VERSION.txt", "r") as file: - PYRIGHT_VERSION = file.readline() + 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:] + 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