Skip to content

Commit d7d8ff9

Browse files
authored
Move requirements to dev dependency group and consistent dep version in tests (#356)
1 parent 7c908c6 commit d7d8ff9

File tree

5 files changed

+41
-43
lines changed

5 files changed

+41
-43
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'Test'
1+
name: "Test"
22

33
on: [push, pull_request, workflow_dispatch]
44

@@ -20,22 +20,20 @@ jobs:
2020
uses: actions/cache@v4
2121
with:
2222
path: ~/.cache/pip
23-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
23+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
2424
restore-keys: |
2525
${{ runner.os }}-pip-
2626
2727
- name: Install dependencies
28-
run:
29-
python -m pip install -r tests/requirements.txt
28+
run: python -m pip install --group tests
3029

3130
- name: Run pyright tests
3231
uses: jakebailey/pyright-action@v2
3332
with:
3433
pylance-version: latest-prerelease
3534

3635
- name: Run mypy tests
37-
run:
38-
python -m mypy .
36+
run: python -m mypy .
3937

4038
hygiene:
4139
runs-on: ubuntu-latest
@@ -47,6 +45,4 @@ jobs:
4745

4846
- name: Run Ruff Linter
4947
uses: astral-sh/ruff-action@v3
50-
with:
51-
version: "0.11.*"
5248
- run: ruff format --check

pyproject.toml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,34 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "microsoft-python-type-stubs"
7-
dynamic = ["version"]
7+
version = "0"
8+
9+
[dependency-groups]
10+
hygiene = ["ruff ==0.11.*"]
11+
tests = [
12+
# Tools used for testing
13+
"docopt-ng",
14+
"mypy ==1.13.*",
15+
"pyright",
16+
17+
# Typed libraries and stubs
18+
"matplotlib >=3.8",
19+
"pandas-stubs",
20+
"pytest",
21+
"scipy-stubs",
22+
"typing_extensions",
23+
24+
# Untyped libraries, used to prevent "reportMissingImports" and get inferred typing
25+
"joblib",
26+
"networkx",
27+
"PyOpenGL",
28+
"scikit-learn",
29+
"sympy",
30+
"traitlets",
31+
"transformers",
32+
]
33+
dev = [{ include-group = "hygiene" }, { include-group = "tests" }]
34+
835

936
# Allow these stubs to be installed from GitHub
1037
# We need an explicit mapping instead of just

tests/requirements.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/run_hygiene.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
def install_requirements():
88
print("\nInstalling requirements...")
9-
return subprocess.run((sys.executable, "-m", "pip", "install", "--upgrade", "ruff"))
9+
subprocess.check_call((sys.executable, "-m", "pip", "install", "pip>=25.1"))
10+
subprocess.check_call((sys.executable, "-m", "pip", "install", "--upgrade", "--group", "hygiene"))
1011

1112

1213
def run_ruff_fix():
@@ -20,11 +21,9 @@ def run_ruff_format():
2021

2122

2223
def main():
23-
test_folder = Path(__file__).parent
24-
root = test_folder.parent
25-
os.chdir(root)
24+
os.chdir(Path(__file__).parent.parent)
2625

27-
install_requirements().check_returncode()
26+
install_requirements()
2827
results = (
2928
run_ruff_fix(),
3029
run_ruff_format(),

tests/run_tests.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
from pathlib import Path
55

66

7-
def install_requirements(test_folder: Path):
7+
def install_requirements():
88
print("\nInstalling requirements...")
9-
return subprocess.run(
10-
(sys.executable, "-m", "pip", "install", "--upgrade", "-r", os.path.join(test_folder, "requirements.txt"))
11-
)
9+
subprocess.check_call((sys.executable, "-m", "pip", "install", "pip>=25.1"))
10+
subprocess.check_call((sys.executable, "-m", "pip", "install", "--upgrade", "--group", "tests"))
1211

1312

1413
def run_pyright():
@@ -25,11 +24,9 @@ def run_mypy():
2524

2625

2726
def main():
28-
test_folder = Path(__file__).parent
29-
root = test_folder.parent
30-
os.chdir(root)
27+
os.chdir(Path(__file__).parent.parent)
3128

32-
install_requirements(test_folder).check_returncode()
29+
install_requirements()
3330
results = (
3431
run_mypy(),
3532
run_pyright(),

0 commit comments

Comments
 (0)