diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a1b6412..112f0928 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: 'Test' +name: "Test" on: [push, pull_request, workflow_dispatch] @@ -20,13 +20,12 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies - run: - python -m pip install -r tests/requirements.txt + run: python -m pip install --group tests - name: Run pyright tests uses: jakebailey/pyright-action@v2 @@ -34,8 +33,7 @@ jobs: pylance-version: latest-prerelease - name: Run mypy tests - run: - python -m mypy . + run: python -m mypy . hygiene: runs-on: ubuntu-latest @@ -47,6 +45,4 @@ jobs: - name: Run Ruff Linter uses: astral-sh/ruff-action@v3 - with: - version: "0.11.*" - run: ruff format --check diff --git a/pyproject.toml b/pyproject.toml index 3bcacb9f..bf17a7bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,34 @@ build-backend = "setuptools.build_meta" [project] name = "microsoft-python-type-stubs" -dynamic = ["version"] +version = "0" + +[dependency-groups] +hygiene = ["ruff ==0.11.*"] +tests = [ + # Tools used for testing + "docopt-ng", + "mypy ==1.13.*", + "pyright", + + # Typed libraries and stubs + "matplotlib >=3.8", + "pandas-stubs", + "pytest", + "scipy-stubs", + "typing_extensions", + + # Untyped libraries, used to prevent "reportMissingImports" and get inferred typing + "joblib", + "networkx", + "PyOpenGL", + "scikit-learn", + "sympy", + "traitlets", + "transformers", +] +dev = [{ include-group = "hygiene" }, { include-group = "tests" }] + # Allow these stubs to be installed from GitHub # We need an explicit mapping instead of just diff --git a/tests/requirements.txt b/tests/requirements.txt deleted file mode 100644 index 40f437c9..00000000 --- a/tests/requirements.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Tools used for testing -docopt-ng -mypy==1.13.* -pyright - -# Typed libraries and stubs -matplotlib>=3.8 -pandas-stubs -pytest -scipy-stubs -typing_extensions - -# Untyped libraries, used to prevent "reportMissingImports" and get inferred typing -joblib -networkx -PyOpenGL -scikit-learn -sympy -traitlets -transformers -transformers diff --git a/tests/run_hygiene.py b/tests/run_hygiene.py index 5766c6c7..97770ee6 100644 --- a/tests/run_hygiene.py +++ b/tests/run_hygiene.py @@ -6,7 +6,8 @@ def install_requirements(): print("\nInstalling requirements...") - return subprocess.run((sys.executable, "-m", "pip", "install", "--upgrade", "ruff")) + subprocess.check_call((sys.executable, "-m", "pip", "install", "pip>=25.1")) + subprocess.check_call((sys.executable, "-m", "pip", "install", "--upgrade", "--group", "hygiene")) def run_ruff_fix(): @@ -20,11 +21,9 @@ def run_ruff_format(): def main(): - test_folder = Path(__file__).parent - root = test_folder.parent - os.chdir(root) + os.chdir(Path(__file__).parent.parent) - install_requirements().check_returncode() + install_requirements() results = ( run_ruff_fix(), run_ruff_format(), diff --git a/tests/run_tests.py b/tests/run_tests.py index e82b4357..5fcd5a8b 100644 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -4,11 +4,10 @@ from pathlib import Path -def install_requirements(test_folder: Path): +def install_requirements(): print("\nInstalling requirements...") - return subprocess.run( - (sys.executable, "-m", "pip", "install", "--upgrade", "-r", os.path.join(test_folder, "requirements.txt")) - ) + subprocess.check_call((sys.executable, "-m", "pip", "install", "pip>=25.1")) + subprocess.check_call((sys.executable, "-m", "pip", "install", "--upgrade", "--group", "tests")) def run_pyright(): @@ -25,11 +24,9 @@ def run_mypy(): def main(): - test_folder = Path(__file__).parent - root = test_folder.parent - os.chdir(root) + os.chdir(Path(__file__).parent.parent) - install_requirements(test_folder).check_returncode() + install_requirements() results = ( run_mypy(), run_pyright(),