Skip to content

Commit 2e69d4b

Browse files
committed
Move requirements to dev dependency group and consistent dep version in tests
1 parent 9c5664c commit 2e69d4b

File tree

6 files changed

+50
-52
lines changed

6 files changed

+50
-52
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.9.*"
5248
- run: ruff format --check

pyproject.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@ build-backend = "setuptools.build_meta"
66
name = "microsoft-python-type-stubs"
77
dynamic = ["version"]
88

9+
[dependency-groups]
10+
hygiene = ["ruff ==0.9.*"]
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+
35+
936
# Allow these stubs to be installed from GitHub
1037
# We need an explicit mapping instead of just
1138
# [tool.setuptools]

stubs/vispy/util/fonts/__init__.pyi

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

77
__all__ = ["list_fonts"]
88

9-
from ._triage import list_fonts as list_fonts # noqa, analysis:ignore
10-
from ._vispy_fonts import _vispy_fonts as _vispy_fonts # noqa, analysis:ignore
9+
from ._triage import list_fonts as list_fonts # analysis:ignore
10+
from ._vispy_fonts import _vispy_fonts as _vispy_fonts # analysis:ignore

tests/requirements.txt

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

tests/run_hygiene.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,27 @@
66

77
def install_requirements():
88
print("\nInstalling requirements...")
9-
return subprocess.run((sys.executable, "-m", "pip", "install", "--upgrade", "isort", "black"))
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

12-
def run_isort():
13-
print("\nRunning isort...")
14-
return subprocess.run((sys.executable, "-m", "isort", "."))
13+
def run_ruff_fix():
14+
print("\nRunning Ruff check --fix...")
15+
return subprocess.run((sys.executable, "-m", "ruff", "check", "--fix"))
1516

1617

17-
def run_black():
18-
print("\nRunning Black...")
19-
return subprocess.run((sys.executable, "-m", "black", "."))
18+
def run_ruff_format():
19+
print("\nRunning Ruff format...")
20+
return subprocess.run((sys.executable, "-m", "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 = (
29-
run_isort(),
30-
run_black(),
28+
run_ruff_fix(),
29+
run_ruff_format(),
3130
)
3231
if sum([result.returncode for result in results]) > 0:
3332
print("\nOne or more tests failed. See above for details.")

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)