From 9df932b7b8fe9935325794e6e8a9ffe00653b60c Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 30 Apr 2023 12:01:03 -0400 Subject: [PATCH] Don't install requirements-tests.txt in pyright tests --- .github/workflows/tests.yml | 6 ++++-- requirements-pyright.txt | 7 +++++++ requirements-tests.txt | 5 +---- tests/check_consistent.py | 13 +++++++++---- 4 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 requirements-pyright.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b5911cfdc53..17f40a852dff 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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" diff --git a/requirements-pyright.txt b/requirements-pyright.txt new file mode 100644 index 000000000000..9aa126f3f13c --- /dev/null +++ b/requirements-pyright.txt @@ -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 diff --git a/requirements-tests.txt b/requirements-tests.txt index 2bcd6b0ec233..9a8187275c05 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,3 +1,4 @@ +-r "requirements-pyright.txt" aiohttp==3.8.4 black==23.3.0 # must match .pre-commit-config.yaml flake8==6.0.0; python_version >= "3.8" # must match .pre-commit-config.yaml @@ -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.11; platform_system != "Windows" and python_version < "3.11" pyyaml==6.0 termcolor>=2.3 -tomli==2.0.1 tomlkit==0.11.7 types-pyyaml>=6.0.12.7 types-setuptools>=67.5.0.0 -typing-extensions diff --git a/tests/check_consistent.py b/tests/check_consistent.py index 976b7fbef636..bf673480fe5a 100644 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -9,6 +9,7 @@ import re import sys import urllib.parse +from collections.abc import Iterator from pathlib import Path from typing import TypedDict @@ -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):