-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Support third-party stub external dependencies in pytype #9449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
79ffad6
45a1366
6a76900
883a6c4
78dcd72
c0aff81
ead2b32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ on: | |
- main | ||
pull_request: | ||
paths-ignore: | ||
- '**/*.md' | ||
- 'scripts/**' | ||
- "**/*.md" | ||
- "scripts/**" | ||
|
||
permissions: | ||
contents: read | ||
|
@@ -69,6 +69,13 @@ jobs: | |
cache: pip | ||
cache-dependency-path: requirements-tests.txt | ||
- run: pip install -r requirements-tests.txt | ||
- name: Install external dependencies for 3rd-party stubs | ||
run: | | ||
DEPENDENCIES=$(python tests/get_external_stub_requirements.py) | ||
if [ -n "$DEPENDENCIES" ]; then | ||
echo "Installing packages: $DEPENDENCIES" | ||
pip install $DEPENDENCIES | ||
fi | ||
- run: ./tests/pytype_test.py --print-stderr | ||
|
||
mypy: | ||
|
@@ -112,12 +119,26 @@ jobs: | |
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
cache: pip | ||
cache-dependency-path: requirements-tests.txt | ||
- name: Install external dependencies for 3rd-party stubs | ||
run: | | ||
pip install -r requirements-tests.txt | ||
DEPENDENCIES=$(python tests/get_external_stub_requirements.py) | ||
if [ -n "$DEPENDENCIES" ]; then | ||
echo "Installing packages: $DEPENDENCIES" | ||
pip install $DEPENDENCIES | ||
fi | ||
- run: pip freeze --all | ||
- name: Get pyright version | ||
uses: SebRollen/[email protected] | ||
id: pyright_version | ||
with: | ||
file: 'pyproject.toml' | ||
field: 'tool.typeshed.pyright_version' | ||
file: "pyproject.toml" | ||
field: "tool.typeshed.pyright_version" | ||
- uses: jakebailey/pyright-action@v1 | ||
with: | ||
version: ${{ steps.pyright_version.outputs.value }} | ||
|
@@ -137,7 +158,7 @@ jobs: | |
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. | ||
no-comments: ${{ matrix.python-version != '3.10' || matrix.python-platform != 'Linux' }} # Having each job create the same comment is too noisy. | ||
|
||
stub-uploader: | ||
name: Run the stub_uploader tests | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
version = "0.5.*" | ||
requires = ["numpy"] | ||
|
||
[tool.stubtest] | ||
ignore_missing_stub = false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
version = "2.0.*" | ||
requires = ["numpy"] | ||
|
||
[tool.stubtest] | ||
ignore_missing_stub = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,18 @@ objects at runtime. | |
in the `tests` and `scripts` directories. | ||
|
||
To run the tests, follow the [setup instructions](../CONTRIBUTING.md#preparing-the-environment) | ||
in the `CONTRIBUTING.md` document. In particular, we recommend running with Python 3.9+. | ||
in the `CONTRIBUTING.md` document. In particular, you have to run with Python 3.9+. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the wording here because since #9382, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In practice we've required 3.9+ for a lot longer, due to the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know. I believe you could still run other tests, so "recommend" wasn't too inaccurate :P I only noticed because I had 3.8 installed in WSL. |
||
|
||
In order for `pytype_test` and `pyright_test` to work correctly, some third-party stubs may require dependencies external to typeshed to be installed in your virtual environment prior to running the test. | ||
You can list or install all of a stubs package's external dependencies using the following script: | ||
```bash | ||
(.venv3)$ python tests/get_external_stub_requirements.py <third_party_stub> # List external dependencies for <third_party_stub> | ||
(.venv3)$ python tests/get_external_stub_requirements.py <third_party_stub1> <third_party_stub2> # List external dependencies for <third_party_stub1> and <third_party_stub2> | ||
(.venv3)$ python tests/get_external_stub_requirements.py # List external dependencies for all third-party stubs in typeshed | ||
# Install external dependencies for all third-party stubs in typeshed | ||
(.venv3)$ DEPENDENCIES=$(python tests/get_external_stub_requirements.py) | ||
(.venv3)$ if [ -n "$DEPENDENCIES" ]; then pip install $DEPENDENCIES; fi | ||
``` | ||
|
||
## Run all tests for a specific stub | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
from __future__ import annotations | ||
|
||
import os | ||
import sys | ||
|
||
from utils import read_dependencies | ||
|
||
distributions = sys.argv[1:] | ||
if not distributions: | ||
distributions = os.listdir("stubs") | ||
|
||
requirements = set[str]() | ||
for distribution in distributions: | ||
requirements.update(read_dependencies(distribution).external_pkgs) | ||
|
||
for requirement in sorted(requirements): | ||
print(requirement) |
Uh oh!
There was an error while loading. Please reload this page.