Skip to content

Commit d208d5a

Browse files
authored
Pyright: create a more isolated environment in CI for testing stubs (python#10121)
1 parent f5a870b commit d208d5a

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

.github/workflows/tests.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,23 @@ jobs:
125125
python-version: "3.10"
126126
cache: pip
127127
cache-dependency-path: requirements-tests.txt
128-
- name: Install external dependencies for 3rd-party stubs
128+
- name: Install typeshed test-suite requirements
129+
# Install these so we can run `get_external_stub_requirements.py`
130+
run: pip install -r requirements-tests.txt
131+
- name: Create an isolated venv for testing
132+
run: python -m venv .venv
133+
- name: Install 3rd-party stub dependencies
129134
run: |
130-
pip install -r requirements-tests.txt
131135
DEPENDENCIES=$(python tests/get_external_stub_requirements.py)
132136
if [ -n "$DEPENDENCIES" ]; then
137+
source .venv/bin/activate
133138
echo "Installing packages: $DEPENDENCIES"
134139
pip install $DEPENDENCIES
135140
fi
136-
- run: pip freeze --all
141+
- name: List 3rd-party stub dependencies installed
142+
run: |
143+
source .venv/bin/activate
144+
pip freeze --all
137145
- name: Get pyright version
138146
uses: SebRollen/toml-action@v1.0.2
139147
id: pyright_version
@@ -147,13 +155,15 @@ jobs:
147155
python-platform: ${{ matrix.python-platform }}
148156
python-version: ${{ matrix.python-version }}
149157
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
158+
venv-path: .
150159
- name: Run pyright with stricter settings on some of the stubs
151160
uses: jakebailey/pyright-action@v1
152161
with:
153162
version: ${{ steps.pyright_version.outputs.value }}
154163
python-platform: ${{ matrix.python-platform }}
155164
python-version: ${{ matrix.python-version }}
156165
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
166+
venv-path: .
157167
project: ./pyrightconfig.stricter.json
158168
- name: Run pyright on the test cases
159169
uses: jakebailey/pyright-action@v1
@@ -162,6 +172,7 @@ jobs:
162172
python-platform: ${{ matrix.python-platform }}
163173
python-version: ${{ matrix.python-version }}
164174
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy.
175+
venv-path: .
165176
project: ./pyrightconfig.testcases.json
166177

167178
stub-uploader:

pyrightconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
33
"typeshedPath": ".",
4+
"venv": ".venv",
45
"include": [
56
"stdlib",
67
"stubs",

pyrightconfig.stricter.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
33
"typeshedPath": ".",
4+
"venv": ".venv",
45
"include": [
56
"stdlib",
67
"stubs",

pyrightconfig.testcases.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json",
33
"typeshedPath": ".",
4+
"venv": ".venv",
45
"include": [
56
"test_cases",
67
"stubs/**/@tests/test_cases"

0 commit comments

Comments
 (0)