Skip to content

Commit 75ddfc6

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/python-type-stubs into Remove-upstream-partial-transformers-stubs
2 parents 9c59019 + aaa9f03 commit 75ddfc6

File tree

42 files changed

+163
-279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+163
-279
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,25 @@ on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
test:
7-
runs-on: ubuntu-latest
7+
runs-on: ${{ matrix.os }}
88
timeout-minutes: 10
9+
strategy:
10+
matrix:
11+
# Oldest non-EOL and newest released
12+
# scipy-stubs does not support Python 3.9
13+
python-version: ["3.10", "3.13"]
14+
# Tier 1 OSes
15+
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
16+
fail-fast: false
917

1018
steps:
1119
- name: Check out code
1220
uses: actions/checkout@v2
1321

14-
- name: Setup Python
22+
- name: Setup Python ${{ matrix.python-version }}
1523
uses: actions/setup-python@v2
1624
with:
17-
python-version: "3.11"
25+
python-version: ${{ matrix.python-version }}
1826

1927
- name: Cache pip
2028
uses: actions/cache@v4
@@ -31,9 +39,10 @@ jobs:
3139
uses: jakebailey/pyright-action@v2
3240
with:
3341
pylance-version: latest-prerelease
42+
python-version: ${{ matrix.python-version }}
3443

3544
- name: Run mypy tests
36-
run: python -m mypy .
45+
run: python -m mypy . --python-version=${{ matrix.python-version }}
3746

3847
hygiene:
3948
runs-on: ubuntu-latest
@@ -45,4 +54,5 @@ jobs:
4554

4655
- name: Run Ruff Linter
4756
uses: astral-sh/ruff-action@v3
48-
- run: ruff format --check
57+
- name: Run Ruff Formatter
58+
run: ruff format --check

pyproject.toml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tests = [
2121
"scipy-stubs",
2222
"typing_extensions",
2323

24-
# Untyped libraries, used to prevent "reportMissingImports" and get inferred typing
24+
# Untyped libraries and partial stubs. Used to prevent "reportMissingImports" and get inferred typing
2525
"joblib",
2626
"networkx",
2727
"PyOpenGL",
@@ -140,15 +140,16 @@ python_version = "3.9" # Target oldest supported Python version
140140
strict = true
141141
check_untyped_defs = true # Strict check on all defs
142142
show_column_numbers = true
143+
# Not all imports in these stubs are gonna be typed
144+
# Don't infer symbols from untyped packages as Any
145+
follow_untyped_imports = true
143146
warn_unused_ignores = false # Change from pandas
144147
# Partial stubs are acceptable
145148
disallow_any_generics = false
146149
disallow_incomplete_defs = false
147150
disallow_untyped_defs = false
148151
# Suppressing errors
149152
disable_error_code = [
150-
# Not all imports in these stubs are gonna be typed
151-
"import-untyped",
152153
# mypy's overload implementation differs from pyright
153154
# `assert-type` issues is tests mostly comme from checking overloads
154155
# Since this project is specific to Pylance, just ignore them
@@ -157,6 +158,18 @@ disable_error_code = [
157158
# as they are inherited from the implementation.
158159
"override",
159160
# TODO
160-
"assignment", # 773 errors in 172 files
161-
"misc", # 692 errors in 132 files
161+
"assignment", # 744 errors in 155 files
162162
]
163+
164+
[[tool.mypy.overrides]]
165+
# These modules are to be removed soon, not worth solving many issues
166+
module = ["matplotlib.*", "networkx.*"]
167+
disable_error_code = [
168+
"assignment",
169+
"misc",
170+
]
171+
[[tool.mypy.overrides]]
172+
module = ["sympy.*", "skimage.*", "sklearn.*"]
173+
# TODO: Too many untyped decorators still left
174+
# https://github.com/python/mypy/issues/19148
175+
disable_error_code = ["misc"]

stubs/matplotlib/_mathtext.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import enum
22
import functools
3-
from tkinter.tix import HList
3+
import sys
4+
from _typeshed import Incomplete
45
from typing import Literal
56

67
from .font_manager import FontProperties
78
from .mathtext import MathtextBackend
89

10+
# tkinter.tix was removed from Python 3.13
11+
# Recent matplotlib versions define HList in this module
12+
if sys.version_info >= (3, 13):
13+
HList: Incomplete
14+
else:
15+
from tkinter.tix import HList
16+
917
def get_unicode_index(symbol: str, math: bool = True) -> int: ...
1018

1119
class Fonts:

stubs/skimage/__init__.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from ._shared.version_requirements import ensure_python_version as ensure_python
44

55
__version__: str = ...
66
submodules: list = ...
7-
__getattr__ = ...
87
__lazy_dir__ = ...
98

109
def __dir__(): ...

stubs/skimage/_shared/setup.pyi

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

stubs/skimage/data/__init__.pyi

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,88 @@
1-
from .._shared import lazy as lazy
1+
from ._binary_blobs import binary_blobs
2+
from ._fetchers import (
3+
astronaut,
4+
brain,
5+
brick,
6+
camera,
7+
cat,
8+
cell,
9+
cells3d,
10+
checkerboard,
11+
chelsea,
12+
clock,
13+
coffee,
14+
coins,
15+
colorwheel,
16+
data_dir,
17+
download_all,
18+
eagle,
19+
file_hash,
20+
grass,
21+
gravel,
22+
horse,
23+
hubble_deep_field,
24+
human_mitosis,
25+
immunohistochemistry,
26+
kidney,
27+
lbp_frontal_face_cascade_filename,
28+
lfw_subset,
29+
lily,
30+
logo,
31+
microaneurysms,
32+
moon,
33+
nickel_solidification,
34+
page,
35+
palisades_of_vogt as palisades_of_vogt,
36+
protein_transport,
37+
retina,
38+
rocket,
39+
shepp_logan_phantom,
40+
skin,
41+
stereo_motorcycle,
42+
text,
43+
vortex,
44+
)
245

3-
__getattr__ = ...
4-
__dir__ = ...
5-
__all__ = ... # pyright: ignore[reportUnsupportedDunderAll] # TODO
46+
__all__ = [
47+
"astronaut",
48+
"binary_blobs",
49+
"brain",
50+
"brick",
51+
"camera",
52+
"cat",
53+
"cell",
54+
"cells3d",
55+
"checkerboard",
56+
"chelsea",
57+
"clock",
58+
"coffee",
59+
"coins",
60+
"colorwheel",
61+
"data_dir",
62+
"download_all",
63+
"eagle",
64+
"file_hash",
65+
"grass",
66+
"gravel",
67+
"horse",
68+
"hubble_deep_field",
69+
"human_mitosis",
70+
"immunohistochemistry",
71+
"kidney",
72+
"lbp_frontal_face_cascade_filename",
73+
"lfw_subset",
74+
"lily",
75+
"logo",
76+
"microaneurysms",
77+
"moon",
78+
"nickel_solidification",
79+
"page",
80+
"protein_transport",
81+
"retina",
82+
"rocket",
83+
"shepp_logan_phantom",
84+
"skin",
85+
"stereo_motorcycle",
86+
"text",
87+
"vortex",
88+
]

stubs/skimage/data/_fetchers.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from os import PathLike
22

3+
def file_hash(fname, alg="sha256") -> str: ...
4+
35
legacy_data_dir = ...
46
skimage_distribution_dir = ...
57

@@ -46,6 +48,7 @@ def hubble_deep_field(): ...
4648
def retina(): ...
4749
def shepp_logan_phantom(): ...
4850
def colorwheel(): ...
51+
def palisades_of_vogt(): ...
4952
def rocket(): ...
5053
def stereo_motorcycle(): ...
5154
def lfw_subset(): ...

stubs/skimage/draw/setup.pyi

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

stubs/skimage/future/graph/setup.pyi

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

stubs/skimage/future/setup.pyi

Lines changed: 0 additions & 1 deletion
This file was deleted.

stubs/skimage/measure/setup.pyi

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

stubs/skimage/morphology/setup.pyi

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

stubs/skimage/setup.pyi

Lines changed: 0 additions & 1 deletion
This file was deleted.

stubs/skimage/transform/setup.pyi

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

stubs/sklearn/__check_build/setup.pyi

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

stubs/sklearn/_loss/setup.pyi

Lines changed: 0 additions & 1 deletion
This file was deleted.

stubs/sklearn/cluster/setup.pyi

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

stubs/sklearn/datasets/setup.pyi

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

stubs/sklearn/decomposition/setup.pyi

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

stubs/sklearn/ensemble/setup.pyi

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

stubs/sklearn/feature_extraction/setup.pyi

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

stubs/sklearn/gaussian_process/kernels.pyi

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,6 @@ class Hyperparameter(NamedTuple):
2323
value_type: str
2424
name: str
2525

26-
# A raw namedtuple is very memory efficient as it packs the attributes
27-
# in a struct to get rid of the __dict__ of attributes in particular it
28-
# does not copy the string for the keys on each instance.
29-
# By deriving a namedtuple class just to introduce the __init__ method we
30-
# would also reintroduce the __dict__ on the instance. By telling the
31-
# Python interpreter that this subclass uses static __slots__ instead of
32-
# dynamic attributes. Furthermore we don't need any additional slot in the
33-
# subclass so we set __slots__ to the empty tuple.
34-
__slots__ = ...
35-
36-
def __new__(
37-
cls,
38-
name: str,
39-
value_type: str,
40-
bounds: ndarray | str | tuple[float, int] | tuple[float, float],
41-
n_elements: int = 1,
42-
fixed=None,
43-
) -> Self: ...
44-
45-
# This is mainly a testing utility to check that two hyperparameters
46-
# are equal.
47-
def __eq__(self, other) -> bool: ...
48-
4926
class Kernel(metaclass=ABCMeta):
5027
def get_params(self, deep: bool = True) -> dict: ...
5128
def set_params(self, **params) -> Self: ...

stubs/sklearn/inspection/setup.pyi

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

stubs/sklearn/linear_model/setup.pyi

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

stubs/sklearn/manifold/setup.pyi

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

0 commit comments

Comments
 (0)