Skip to content

Don't install types-* dependencies in pyright tests #10120

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ jobs:
with:
python-version: "3.10"
cache: pip
cache-dependency-path: requirements-tests.txt
cache-dependency-path: |
requirements-pyright.txt
stubs/**/METADATA.toml
- name: Install external dependencies for 3rd-party stubs
run: |
pip install -r requirements-tests.txt
pip install -r requirements-pyright.txt
DEPENDENCIES=$(python tests/get_external_stub_requirements.py)
if [ -n "$DEPENDENCIES" ]; then
echo "Installing packages: $DEPENDENCIES"
Expand Down
7 changes: 7 additions & 0 deletions requirements-pyright.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Don't install everything from requirements-tests.txt for pyright tests on CI
# Only what's needed to run `get_external_stub_requirements.py`
# We specifically need to avoid installing `types-*`
packaging==23.1
pathspec>=0.10.3
tomli==2.0.1
typing-extensions
5 changes: 1 addition & 4 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-r "requirements-pyright.txt"
aiohttp==3.8.4; python_version < "3.12" # aiohttp can't be installed on 3.12 yet
black==23.3.0 # must match .pre-commit-config.yaml
flake8==6.0.0; python_version >= "3.8" # must match .pre-commit-config.yaml
Expand All @@ -6,15 +7,11 @@ flake8-noqa==1.3.1; python_version >= "3.8" # must match .pre-commit-confi
flake8-pyi==23.4.1; python_version >= "3.8" # must match .pre-commit-config.yaml
isort==5.12.0; python_version >= "3.8" # must match .pre-commit-config.yaml
mypy==1.2.0
packaging==23.1
pathspec>=0.10.3
pre-commit-hooks==4.4.0 # must match .pre-commit-config.yaml
pycln==2.1.3 # must match .pre-commit-config.yaml
pytype==2023.4.27; platform_system != "Windows" and python_version < "3.11"
pyyaml==6.0
termcolor>=2.3
tomli==2.0.1
tomlkit==0.11.8
types-pyyaml>=6.0.12.7
types-setuptools>=67.5.0.0
typing-extensions
13 changes: 9 additions & 4 deletions tests/check_consistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import sys
import urllib.parse
from collections.abc import Iterator
from pathlib import Path
from typing import TypedDict

Expand Down Expand Up @@ -135,10 +136,14 @@ def check_metadata() -> None:


def get_txt_requirements() -> dict[str, SpecifierSet]:
with open("requirements-tests.txt", encoding="UTF-8") as requirements_file:
stripped_lines = map(strip_comments, requirements_file)
requirements = map(Requirement, filter(None, stripped_lines))
return {requirement.name: requirement.specifier for requirement in requirements}
requirements: list[Requirement] = []
for requirements_path in ("requirements-tests.txt", "requirements-pyright.txt"):
with open(requirements_path, encoding="UTF-8") as requirements_file:
stripped_lines: Iterator[str] = map(strip_comments, requirements_file)
stripped_lines = filter(lambda line: not line.startswith("-r "), stripped_lines)
requirements.extend(map(Requirement, filter(None, stripped_lines)))

return {requirement.name: requirement.specifier for requirement in requirements}


class PreCommitConfigRepos(TypedDict):
Expand Down