Skip to content

Move requirements to dev dependency group and consistent dep version in tests #356

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

Merged
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
12 changes: 4 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Test'
name: "Test"

on: [push, pull_request, workflow_dispatch]

Expand All @@ -20,22 +20,20 @@ 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
with:
pylance-version: latest-prerelease

- name: Run mypy tests
run:
python -m mypy .
run: python -m mypy .

hygiene:
runs-on: ubuntu-latest
Expand All @@ -47,6 +45,4 @@ jobs:

- name: Run Ruff Linter
uses: astral-sh/ruff-action@v3
with:
version: "0.11.*"
- run: ruff format --check
29 changes: 28 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a new issue, but I'm curious why we're testing against matplotlib >=3.8 since those are the versions for which matplotlib ships their own stubs. 3.8.0 shipped back in September 2023. I wonder when we'll be comfortable removing our matplotlib stubs.

Copy link
Contributor Author

@Avasam Avasam May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skimage, sklearn and sympy all reference matplotlib !
Here it's considered "a typed library external to "python-type-stubs".
You want to test against matplotlib >=3.8 specifically because it's the version that provides their own types.

So once matplotlib stubs are removed from this repo, this line should stay.

"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
Expand Down
21 changes: 0 additions & 21 deletions tests/requirements.txt

This file was deleted.

9 changes: 4 additions & 5 deletions tests/run_hygiene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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(),
Expand Down
13 changes: 5 additions & 8 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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(),
Expand Down