Skip to content

Commit 588b849

Browse files
committed
Fix all reportAssertTypeFailure+reportGeneralTypeIssues
1 parent c7c8e26 commit 588b849

File tree

9 files changed

+52
-50
lines changed

9 files changed

+52
-50
lines changed

out/sklearn/utils/fixes.pyi

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from _typeshed import Incomplete
2+
from numpy import ComplexWarning as ComplexWarning, VisibleDeprecationWarning as VisibleDeprecationWarning
3+
from scipy.integrate import trapz as trapezoid
4+
from scipy.optimize.linesearch import line_search_wolfe1 as line_search_wolfe1, line_search_wolfe2 as line_search_wolfe2
5+
from scipy.sparse import csr_array as csr_array, sparray as sparray
6+
from scipy.sparse.csgraph import laplacian as laplacian
7+
8+
np_version: Incomplete
9+
np_base_version: Incomplete
10+
sp_version: Incomplete
11+
sp_base_version: Incomplete
12+
CSR_CONTAINERS: Incomplete
13+
CSC_CONTAINERS: Incomplete
14+
COO_CONTAINERS: Incomplete
15+
LIL_CONTAINERS: Incomplete
16+
DOK_CONTAINERS: Incomplete
17+
BSR_CONTAINERS: Incomplete
18+
DIA_CONTAINERS: Incomplete
19+
SPARRAY_PRESENT: bool
20+
SPARSE_ARRAY_PRESENT: bool
21+
percentile: Incomplete
22+
23+
def pd_fillna(pd, frame): ...
24+
def tarfile_extractall(tarfile, path) -> None: ...

pyproject.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ extra-standard-library = [
8484

8585
[tool.pyright]
8686
exclude = ["build", ".git"]
87+
stubPath = "./stubs"
8788
# Target oldest supported Python version
8889
pythonversion = "3.9"
8990
typeCheckingMode = "standard"
@@ -108,10 +109,6 @@ reportSelfClsParameterName = false
108109
# Not an error by default in standard mode
109110
reportUnsupportedDunderAll = "error"
110111

111-
# Error reports to fix in code
112-
reportAssertTypeFailure = "none" # TODO
113-
reportGeneralTypeIssues = "none" # TODO
114-
115112
[tool.mypy]
116113
# Target oldest supported Python version
117114
python_version = "3.9"

stubs/matplotlib/figure.pyi

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class FigureBase(Artist):
7575
def add_artist(self, artist: Artist, clip: bool = False) -> Artist: ...
7676
def add_axes(self, *args, **kwargs) -> Axes: ...
7777
@overload
78-
def add_subplot(self, *args, projection: Literal["3d"], **kwargs) -> Axes3D: ...
78+
# Decorators make this look like a callable. This is an upstream issue
79+
def add_subplot(self, *args, projection: Literal["3d"], **kwargs) -> Axes3D: ... # pyright: ignore[reportGeneralTypeIssues]
7980
@overload
8081
def add_subplot(self, *args, projection: Literal["aitoff"], **kwargs) -> AitoffAxes: ...
8182
@overload

stubs/sklearn/utils/fixes.pyi

+20-40
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,23 @@
1-
import sys
2-
from importlib import resources as resources
3-
from typing import Literal, Mapping
4-
5-
import numpy as np
6-
import scipy
7-
import scipy.stats
8-
import sklearn
9-
import threadpoolctl
10-
from numpy import percentile as percentile
11-
from scipy.linalg import eigh as _eigh
12-
from scipy.optimize._linesearch import ( # explicitly re-exported
13-
line_search_wolfe1 as line_search_wolfe1,
14-
line_search_wolfe2 as line_search_wolfe2,
15-
)
16-
from threadpoolctl import _ThreadpoolLimiter
17-
18-
from ..externals._lobpcg import lobpcg as lobpcg
19-
from ..externals._packaging.version import parse as parse_version
20-
from .deprecation import deprecated
21-
from .parallel import delayed
1+
# Version-based re-exports
2+
from numpy import ComplexWarning as ComplexWarning, VisibleDeprecationWarning as VisibleDeprecationWarning
3+
from scipy.integrate import trapezoid as trapezoid
4+
from scipy.optimize._linesearch import line_search_wolfe1 as line_search_wolfe1, line_search_wolfe2 as line_search_wolfe2
5+
from scipy.sparse.csgraph import laplacian as laplacian
226

237
np_version = ...
8+
np_base_version = ...
249
sp_version = ...
25-
26-
class loguniform(scipy.stats.reciprocal): ...
27-
28-
def threadpool_limits(
29-
limits: None | Mapping | str | int = None,
30-
user_api: None | Literal["blas", "openmp"] = None,
31-
) -> _ThreadpoolLimiter: ...
32-
33-
threadpool_limits.__doc__ = ...
34-
35-
def threadpool_info() -> list[dict[str, int | str] | dict[str, str | None | int]]: ...
36-
37-
threadpool_info.__doc__ = ...
38-
39-
@deprecated(
40-
"The function `delayed` has been moved from `sklearn.utils.fixes` to "
41-
"`sklearn.utils.parallel`. This import path will be removed in 1.5."
42-
)
43-
def delayed(function): ...
10+
sp_base_version = ...
11+
CSR_CONTAINERS = ...
12+
CSC_CONTAINERS = ...
13+
COO_CONTAINERS = ...
14+
LIL_CONTAINERS = ...
15+
DOK_CONTAINERS = ...
16+
BSR_CONTAINERS = ...
17+
DIA_CONTAINERS = ...
18+
SPARRAY_PRESENT: bool
19+
SPARSE_ARRAY_PRESENT: bool
20+
percentile = ...
21+
22+
def pd_fillna(pd, frame): ...
23+
def tarfile_extractall(tarfile, path) -> None: ...

stubs/sympy-stubs/polys/domains/gmpyintegerring.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class GMPYIntegerRing(IntegerRing):
99
dtype = GMPYInteger
1010
zero = dtype(0)
1111
one = dtype(1)
12-
tp = type(one)
12+
tp: type[dtype]
1313
alias = ...
1414
def __init__(self) -> None: ...
1515
def to_sympy(self, a) -> Integer: ...

stubs/sympy-stubs/polys/domains/gmpyrationalfield.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class GMPYRationalField(RationalField):
99
dtype = GMPYRational
1010
zero = dtype(0)
1111
one = dtype(1)
12-
tp = type(one)
12+
tp: type[dtype]
1313
alias = ...
1414
def __init__(self) -> None: ...
1515
def get_ring(self) -> Any: ...

stubs/sympy-stubs/polys/domains/integerring.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class IntegerRing(Ring, CharacteristicZero, SimpleDomain): # type: ignore
1313
dtype = MPZ
1414
zero = dtype(0)
1515
one = dtype(1)
16-
tp = type(one)
16+
tp: type[dtype]
1717
is_ZZ = ...
1818
is_Numerical = ...
1919
is_PID = ...

stubs/sympy-stubs/polys/domains/rationalfield.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RationalField(Field, CharacteristicZero, SimpleDomain):
1919
dtype = MPQ
2020
zero = dtype(0)
2121
one = dtype(1)
22-
tp = type(one)
22+
tp: type[dtype]
2323
def __init__(self) -> None: ...
2424
def get_ring(self) -> Any: ...
2525
def to_sympy(self, a) -> Rational | Integer: ...

utils/validate_stubs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/python
2+
from __future__ import annotations
23

34
__doc__ = """Validate Stubs.
45
@@ -14,7 +15,6 @@
1415
--function=<f> Restrict to the named function (or method if used with --class).
1516
--class=<c> Restrict to the named class.
1617
"""
17-
from __future__ import annotations
1818

1919
import importlib
2020
import importlib.machinery

0 commit comments

Comments
 (0)