Skip to content
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

Support external-dependencies in pyright #9434

Merged
merged 22 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ 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 3rd-party dependencies for stubs packages
run: |
pip install -r requirements-tests.txt
DEPENDENCIES=$(python tests/get_external_dependencies.py)
if [ -n "$DEPENDENCIES" ]; then
echo "Installing packages: $DEPENDENCIES"
pip install $DEPENDENCIES
fi
- run: pip freeze --all
- name: Get pyright version
uses: SebRollen/toml-action@v1.0.2
id: pyright_version
Expand Down
11 changes: 11 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ checks that would typically fail on incomplete stubs (such as `Unknown` checks).
In typeshed's CI, pyright is run with these configuration settings on a subset of
the stubs in typeshed (including the standard library).

In order for `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_dependencies.py <third_party_stub> # List external dependencies for <third_party_stub>
(.venv3)$ python tests/get_external_dependencies.py <third_party_stub1> <third_party_stub2> # List external dependencies for <third_party_stub1> and <third_party_stub2>
(.venv3)$ python tests/get_external_dependencies.py # List external dependencies for all third-party packages in typeshed
# Install external dependencies for all third-party stubs packages in typeshed
(.venv3)$ DEPENDENCIES=$(python tests/get_external_dependencies.py)
(.venv3)$ if [ -n "$DEPENDENCIES" ]; then pip install $DEPENDENCIES; fi
```

## regr\_test.py

This test runs mypy against the test cases for typeshed's stdlib and third-party
Expand Down
18 changes: 18 additions & 0 deletions tests/get_external_dependencies.py
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)
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import subprocess
import sys
import venv
from collections.abc import Mapping
from collections.abc import Iterable, Mapping
from functools import cache
from pathlib import Path
from typing import Iterable, NamedTuple
from typing import NamedTuple
from typing_extensions import Annotated

import pathspec # type: ignore[import]
Expand Down