Skip to content

Commit 5c3f10e

Browse files
AvasamAlexWaygood
andauthored
Deduplicate pinned pyright version (#9299)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent df0a062 commit 5c3f10e

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,31 @@ jobs:
110110
python-platform: ["Linux", "Windows", "Darwin"]
111111
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
112112
fail-fast: false
113-
env:
114-
PYRIGHT_VERSION: 1.1.278 # Must match pyright_test.py.
115113
steps:
116114
- uses: actions/checkout@v3
115+
- name: Get pyright version
116+
uses: SebRollen/toml-action@v1.0.2
117+
id: pyright_version
118+
with:
119+
file: 'pyproject.toml'
120+
field: 'tool.typeshed.pyright_version'
117121
- uses: jakebailey/pyright-action@v1
118122
with:
119-
version: ${{ env.PYRIGHT_VERSION }}
123+
version: ${{ steps.pyright_version.outputs.value }}
120124
python-platform: ${{ matrix.python-platform }}
121125
python-version: ${{ matrix.python-version }}
122126
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
123127
project: ./pyrightconfig.stricter.json
124128
- uses: jakebailey/pyright-action@v1
125129
with:
126-
version: ${{ env.PYRIGHT_VERSION }}
130+
version: ${{ steps.pyright_version.outputs.value }}
127131
python-platform: ${{ matrix.python-platform }}
128132
python-version: ${{ matrix.python-version }}
129133
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
130134
project: ./pyrightconfig.testcases.json
131135
- uses: jakebailey/pyright-action@v1
132136
with:
133-
version: ${{ env.PYRIGHT_VERSION }}
137+
version: ${{ steps.pyright_version.outputs.value }}
134138
python-platform: ${{ matrix.python-platform }}
135139
python-version: ${{ matrix.python-version }}
136140
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@ extra_standard_library = [
5959
[tool.pycln]
6060
all = true
6161
disable_all_dunder_policy = true
62+
63+
[tool.typeshed]
64+
pyright_version = "1.1.278"

tests/pyright_test.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import sys
77
from pathlib import Path
88

9-
_PYRIGHT_VERSION = "1.1.278" # Must match .github/workflows/tests.yml.
9+
import tomli
10+
1011
_WELL_KNOWN_FILE = Path("tests", "pyright_test.py")
1112

1213

@@ -28,8 +29,11 @@ def main() -> None:
2829
print("error running npx; is Node.js installed?", file=sys.stderr)
2930
sys.exit(1)
3031

31-
os.environ["PYRIGHT_PYTHON_FORCE_VERSION"] = _PYRIGHT_VERSION
32-
command = [npx, f"pyright@{_PYRIGHT_VERSION}"] + sys.argv[1:]
32+
with open("pyproject.toml", "rb") as config:
33+
pyright_version: str = tomli.load(config)["tool"]["typeshed"]["pyright_version"]
34+
35+
os.environ["PYRIGHT_PYTHON_FORCE_VERSION"] = pyright_version
36+
command = [npx, f"pyright@{pyright_version}"] + sys.argv[1:]
3337
print("Running:", " ".join(command))
3438

3539
ret = subprocess.run(command).returncode

0 commit comments

Comments
 (0)