Skip to content

Commit cd3e027

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/python-type-stubs into mypy--Fix-all-no-untyped-call
2 parents a77a151 + d7d8ff9 commit cd3e027

File tree

15 files changed

+43
-71
lines changed

15 files changed

+43
-71
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: 29 additions & 2 deletions
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
@@ -33,6 +60,7 @@ extend-select = [
3360
"PYI", # flake8-pyi
3461
"UP", # pyupgrade
3562
"W", # pycodestyle Warning
63+
"PIE790", # unnecessary-placeholder
3664
]
3765
ignore = [
3866
###
@@ -55,7 +83,6 @@ ignore = [
5583
"F401",
5684

5785
# TODO: Investigate and fix or configure
58-
"PYI048",
5986
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
6087
]
6188
[tool.ruff.lint.per-file-ignores]

stubs/sklearn/cluster/_k_means_elkan.pyi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def init_bounds_dense(
4141
n_threads : int
4242
The number of threads to be used by openmp.
4343
"""
44-
...
4544

4645
def init_bounds_sparse(
4746
X: spmatrix,
@@ -83,7 +82,6 @@ def init_bounds_sparse(
8382
n_threads : int
8483
The number of threads to be used by openmp.
8584
"""
86-
...
8785

8886
def elkan_iter_chunked_dense(
8987
X: np.ndarray,
@@ -141,7 +139,6 @@ def elkan_iter_chunked_dense(
141139
the algorithm. This is useful especially when calling predict on a
142140
fitted model.
143141
"""
144-
...
145142

146143
def elkan_iter_chunked_sparse(
147144
X: spmatrix,
@@ -199,4 +196,3 @@ def elkan_iter_chunked_sparse(
199196
the algorithm. This is useful especially when calling predict on a
200197
fitted model.
201198
"""
202-
...

stubs/sklearn/cluster/_k_means_lloyd.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def lloyd_iter_chunked_dense(
4444
the algorithm. This is useful especially when calling predict on a
4545
fitted model.
4646
"""
47-
...
4847

4948
def lloyd_iter_chunked_sparse(
5049
X: np.ndarray,
@@ -90,4 +89,3 @@ def lloyd_iter_chunked_sparse(
9089
the algorithm. This is useful especially when calling predict on a
9190
fitted model.
9291
"""
93-
...

stubs/sklearn/decomposition/_online_lda_fast.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ def mean_change(arr_1: np.ndarray, arr_2: np.ndarray) -> float:
55
66
Equivalent to np.abs(arr_1 - arr2).mean().
77
"""
8-
...
98

109
def psi(x: float) -> float: ...

stubs/sklearn/ensemble/_gradient_boosting.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ def predict_stages(estimators: np.ndarray, X, scale: float, out: np.ndarray) ->
55
Each estimator is scaled by ``scale`` before its prediction
66
is added to ``out``.
77
"""
8-
...
98

109
def predict_stage(estimators: np.ndarray, stage: int, X, scale: float, out: np.ndarray) -> None:
1110
"""Add predictions of ``estimators[stage]`` to ``out``.
1211
Each estimator in the stage is scaled by ``scale`` before
1312
its prediction is added to ``out``.
1413
"""
15-
...

stubs/sklearn/ensemble/_hist_gradient_boosting/histogram.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class HistogramBuilder:
5858
histograms : ndarray of HISTOGRAM_DTYPE, shape (n_features, n_bins)
5959
The computed histograms of the current node.
6060
"""
61-
...
6261

6362
def compute_histograms_subtraction(
6463
self,
@@ -85,4 +84,3 @@ class HistogramBuilder:
8584
histograms : ndarray of HISTOGRAM_DTYPE, shape(n_features, n_bins)
8685
The computed histograms of the current node.
8786
"""
88-
...

stubs/sklearn/ensemble/_hist_gradient_boosting/splitting.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ class Splitter:
159159
right_child_position : int
160160
The position of the right child in ``sample_indices``.
161161
"""
162-
...
163162

164163
def find_node_split(
165164
self,
@@ -208,4 +207,3 @@ class Splitter:
208207
best_split_info : SplitInfo
209208
The info about the best possible split among all features.
210209
"""
211-
...

stubs/sklearn/feature_extraction/_hashing_fast.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ def transform(
88
indices, indptr, values : lists
99
For constructing a scipy.sparse.csr_matrix.
1010
"""
11-
...

stubs/sklearn/metrics/_pairwise_distances_reduction/_dispatcher.pyi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def sqeuclidean_row_norms(X: np.ndarray | csr_matrix, num_threads: int) -> np.nd
2020
sqeuclidean_row_norms : ndarray of shape (n_samples,)
2121
Arrays containing the squared euclidean norm of each row of X.
2222
"""
23-
...
2423

2524
class BaseDistancesReductionDispatcher:
2625
"""Abstract base dispatcher for pairwise distance computation & reduction.
@@ -53,7 +52,6 @@ class BaseDistancesReductionDispatcher:
5352
-------
5453
True if the dispatcher can be used, else False.
5554
"""
56-
...
5755

5856
@classmethod
5957
@abstractmethod
@@ -170,7 +168,6 @@ class ArgKmin(BaseDistancesReductionDispatcher):
170168
for the concrete implementation are therefore freed when this classmethod
171169
returns.
172170
"""
173-
...
174171

175172
class RadiusNeighbors(BaseDistancesReductionDispatcher):
176173
"""Compute radius-based neighbors for two sets of vectors.
@@ -286,4 +283,3 @@ class RadiusNeighbors(BaseDistancesReductionDispatcher):
286283
for the concrete implementation are therefore freed when this classmethod
287284
returns.
288285
"""
289-
...

stubs/sklearn/utils/arrayfuncs.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ def min_pos(X: np.ndarray) -> float:
55
Returns the maximum representable value of the input dtype if none of the
66
values are positive.
77
"""
8-
...
98

109
def cholesky_delete(L: np.ndarray, go_out: int) -> None: ...

stubs/sklearn/utils/sparsefuncs_fast.pyi

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ from scipy.sparse import csc_matrix, csr_matrix
33

44
def csr_row_norms(X: np.ndarray) -> np.ndarray:
55
"""Squared L2 norm of each row in CSR matrix X."""
6-
...
76

87
def csr_mean_variance_axis0(
98
X: csr_matrix, weights: np.ndarray | None = None, return_sum_weights: bool = False
@@ -29,7 +28,6 @@ def csr_mean_variance_axis0(
2928
sum_weights : ndarray of shape (n_features,), dtype=floating
3029
Returned if return_sum_weights is True.
3130
"""
32-
...
3331

3432
def csc_mean_variance_axis0(
3533
X: csc_matrix, weights: np.ndarray | None = None, return_sum_weights: bool = False
@@ -55,7 +53,6 @@ def csc_mean_variance_axis0(
5553
sum_weights : ndarray of shape (n_features,), dtype=floating
5654
Returned if return_sum_weights is True.
5755
"""
58-
...
5956

6057
def incr_mean_variance_axis0(
6158
X: csr_matrix | csc_matrix, last_mean: np.ndarray, last_var: np.ndarray, last_n: np.ndarray, weights: np.ndarray | None = None
@@ -86,15 +83,12 @@ def incr_mean_variance_axis0(
8683
updated_n : int array with shape (n_features,)
8784
Updated number of samples seen
8885
"""
89-
...
9086

9187
def inplace_csr_row_normalize_l1(X: np.ndarray) -> None:
9288
"""Inplace row normalize using the l1 norm"""
93-
...
9489

9590
def inplace_csr_row_normalize_l2(X: np.ndarray) -> None:
9691
"""Inplace row normalize using the l2 norm"""
97-
...
9892

9993
def assign_rows_csr(
10094
X: csr_matrix,
@@ -112,4 +106,3 @@ def assign_rows_csr(
112106
out_rows : array, dtype=np.intp, shape=n_rows
113107
out : array, shape=(arbitrary, n_features)
114108
"""
115-
...

tests/requirements.txt

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

tests/run_hygiene.py

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

66

7-
def install_requirements() -> subprocess.CompletedProcess[bytes]:
7+
def install_requirements() -> None:
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() -> subprocess.CompletedProcess[bytes]:
@@ -20,11 +21,9 @@ def run_ruff_format() -> subprocess.CompletedProcess[bytes]:
2021

2122

2223
def main() -> None:
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) -> subprocess.CompletedProcess[bytes]:
7+
def install_requirements() -> None:
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() -> subprocess.CompletedProcess[bytes]:
@@ -25,11 +24,9 @@ def run_mypy() -> subprocess.CompletedProcess[bytes]:
2524

2625

2726
def main() -> None:
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)