Fix all reportAssertTypeFailure+reportGeneralTypeIssues (#339)

This commit is contained in:
Avasam 2024-11-08 10:16:46 -05:00 коммит произвёл GitHub
Родитель c7c8e26ce2
Коммит ca8036b836
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
23 изменённых файлов: 41 добавлений и 68 удалений

Просмотреть файл

@ -84,6 +84,7 @@ extra-standard-library = [
[tool.pyright]
exclude = ["build", ".git"]
stubPath = "./stubs"
# Target oldest supported Python version
pythonversion = "3.9"
typeCheckingMode = "standard"
@ -108,10 +109,6 @@ reportSelfClsParameterName = false
# Not an error by default in standard mode
reportUnsupportedDunderAll = "error"
# Error reports to fix in code
reportAssertTypeFailure = "none" # TODO
reportGeneralTypeIssues = "none" # TODO
[tool.mypy]
# Target oldest supported Python version
python_version = "3.9"

Просмотреть файл

@ -75,7 +75,8 @@ class FigureBase(Artist):
def add_artist(self, artist: Artist, clip: bool = False) -> Artist: ...
def add_axes(self, *args, **kwargs) -> Axes: ...
@overload
def add_subplot(self, *args, projection: Literal["3d"], **kwargs) -> Axes3D: ...
# Decorators make this look like a callable. This is an upstream issue
def add_subplot(self, *args, projection: Literal["3d"], **kwargs) -> Axes3D: ... # pyright: ignore[reportGeneralTypeIssues]
@overload
def add_subplot(self, *args, projection: Literal["aitoff"], **kwargs) -> AitoffAxes: ...
@overload

Просмотреть файл

@ -18,7 +18,6 @@ from ..utils._param_validation import (
)
from ..utils._readonly_array_wrapper import ReadonlyArrayWrapper as ReadonlyArrayWrapper
from ..utils.extmath import row_norms as row_norms, stable_cumsum as stable_cumsum
from ..utils.fixes import threadpool_info as threadpool_info, threadpool_limits as threadpool_limits
from ..utils.sparsefuncs import mean_variance_axis as mean_variance_axis
from ..utils.sparsefuncs_fast import assign_rows_csr as assign_rows_csr
from ..utils.validation import check_is_fitted as check_is_fitted

Просмотреть файл

@ -20,7 +20,6 @@ from .datasets import (
fetch_rcv1 as fetch_rcv1,
)
from .tests import random_seed as random_seed
from .utils.fixes import parse_version as parse_version
dataset_fetchers: dict = ...

Просмотреть файл

@ -10,7 +10,6 @@ from ..exceptions import ConvergenceWarning as ConvergenceWarning
from ..utils import check_array as check_array, check_consistent_length as check_consistent_length
from ..utils._param_validation import Interval as Interval, StrOptions as StrOptions
from ..utils.extmath import svd_flip as svd_flip
from ..utils.fixes import parse_version as parse_version, sp_version as sp_version
from ..utils.validation import FLOAT_DTYPES as FLOAT_DTYPES, check_is_fitted as check_is_fitted
PLSSVD_Self = TypeVar("PLSSVD_Self", bound="PLSSVD")

Просмотреть файл

@ -9,7 +9,6 @@ from .._typing import ArrayLike, Float, MatrixLike
from ..base import BaseEstimator, RegressorMixin
from ..exceptions import ConvergenceWarning as ConvergenceWarning
from ..utils._param_validation import Hidden as Hidden, Interval as Interval, StrOptions as StrOptions
from ..utils.fixes import parse_version as parse_version, sp_version as sp_version
from ._base import LinearModel
QuantileRegressor_Self = TypeVar("QuantileRegressor_Self", bound="QuantileRegressor")

Просмотреть файл

@ -15,7 +15,6 @@ from ..metrics.pairwise import rbf_kernel as rbf_kernel
from ..neighbors import NearestNeighbors as NearestNeighbors, kneighbors_graph as kneighbors_graph
from ..utils import check_array as check_array, check_random_state as check_random_state, check_symmetric as check_symmetric
from ..utils._param_validation import Interval as Interval, StrOptions as StrOptions
from ..utils.fixes import lobpcg
SpectralEmbedding_Self = TypeVar("SpectralEmbedding_Self", bound="SpectralEmbedding")

Просмотреть файл

@ -23,7 +23,6 @@ from ..utils import (
is_scalar_nan as is_scalar_nan,
)
from ..utils.extmath import row_norms as row_norms, safe_sparse_dot as safe_sparse_dot
from ..utils.fixes import parse_version as parse_version, sp_version as sp_version
from ..utils.parallel import Parallel as Parallel, delayed as delayed
from ..utils.validation import check_non_negative as check_non_negative
from ._pairwise_distances_reduction import ArgKmin as ArgKmin

Просмотреть файл

@ -26,7 +26,6 @@ from ..metrics._pairwise_distances_reduction import ArgKmin as ArgKmin, RadiusNe
from ..metrics.pairwise import PAIRWISE_DISTANCE_FUNCTIONS as PAIRWISE_DISTANCE_FUNCTIONS
from ..utils import check_array as check_array, gen_even_slices as gen_even_slices
from ..utils._param_validation import Interval as Interval, StrOptions as StrOptions
from ..utils.fixes import parse_version as parse_version, sp_version as sp_version
from ..utils.multiclass import check_classification_targets as check_classification_targets
from ..utils.parallel import Parallel as Parallel, delayed as delayed
from ..utils.validation import check_is_fitted as check_is_fitted, check_non_negative as check_non_negative

Просмотреть файл

@ -17,12 +17,12 @@ from scipy.sparse import issparse as issparse
from .. import get_config as get_config
from .._typing import ArrayLike, Int, MatrixLike
from ..exceptions import DataConversionWarning as DataConversionWarning
from . import metadata_routing
from ._bunch import Bunch as Bunch
from ._estimator_html_repr import estimator_html_repr as estimator_html_repr
from .class_weight import compute_class_weight as compute_class_weight, compute_sample_weight as compute_sample_weight
from .deprecation import deprecated as deprecated
from .discovery import all_estimators as all_estimators
from .fixes import parse_version as parse_version, threadpool_info as threadpool_info
from .murmurhash import murmurhash3_32 as murmurhash3_32
from .validation import (
as_float_array as as_float_array,
@ -59,17 +59,20 @@ __all__ = [
"check_scalar",
"indexable",
"check_symmetric",
"indices_to_mask",
"deprecated",
"parallel_backend",
"register_parallel_backend",
"resample",
"shuffle",
"check_matplotlib_support",
"all_estimators",
"DataConversionWarning",
"estimator_html_repr",
"Bunch",
"metadata_routing",
"safe_sqr",
"safe_mask",
"gen_batches",
"gen_even_slices",
]
IS_PYPY = ...

Просмотреть файл

@ -1,8 +1,6 @@
import platform
import sys
from ..utils.fixes import threadpool_info as threadpool_info
# License: BSD 3 clause
def show_versions(): ...

Просмотреть файл

@ -51,7 +51,6 @@ from numpy.testing import (
from .._typing import ArrayLike, Float, Int, MatrixLike
from ..metrics import accuracy_score as accuracy_score, r2_score as r2_score
from . import IS_PYPY as IS_PYPY
from .fixes import threadpool_info as threadpool_info
from .multiclass import check_classification_targets as check_classification_targets
from .validation import check_array as check_array, check_is_fitted as check_is_fitted, check_X_y as check_X_y
@ -64,7 +63,8 @@ __all__ = [
"assert_array_less",
"assert_approx_equal",
"assert_allclose",
"assert_run_python_script",
"assert_run_python_script_without_output",
"assert_no_warnings",
"SkipTest",
]
@ -116,6 +116,7 @@ class TempMemmap:
def __exit__(self, exc_type, exc_val, exc_tb): ...
def create_memmap_backed_data(data, mmap_mode: str = "r", return_folder: bool = False, aligned: bool = False): ...
def assert_run_python_script_without_output(source_code, pattern=".+", timeout=60) -> None: ...
def check_docstring_parameters(func: Callable, doc: None | str = None, ignore: Sequence | None = None) -> ndarray: ...
def assert_run_python_script(source_code: str, timeout: Int = 60): ...
def raises(

Просмотреть файл

@ -56,7 +56,6 @@ from ..utils._param_validation import (
generate_invalid_param_val as generate_invalid_param_val,
make_constraint as make_constraint,
)
from ..utils.fixes import parse_version as parse_version, sp_version as sp_version
from ..utils.validation import check_is_fitted as check_is_fitted
from . import IS_PYPY as IS_PYPY, is_scalar_nan as is_scalar_nan, shuffle as shuffle
from ._param_validation import Interval as Interval

Просмотреть файл

@ -1,43 +1,23 @@
import sys
from importlib import resources as resources
from typing import Literal, Mapping
import numpy as np
import scipy
import scipy.stats
import sklearn
import threadpoolctl
from numpy import percentile as percentile
from scipy.linalg import eigh as _eigh
from scipy.optimize._linesearch import ( # explicitly re-exported
line_search_wolfe1 as line_search_wolfe1,
line_search_wolfe2 as line_search_wolfe2,
)
from threadpoolctl import _ThreadpoolLimiter
from ..externals._lobpcg import lobpcg as lobpcg
from ..externals._packaging.version import parse as parse_version
from .deprecation import deprecated
from .parallel import delayed
# Version-based re-exports
from numpy.exceptions import ComplexWarning as ComplexWarning, VisibleDeprecationWarning as VisibleDeprecationWarning
from scipy.integrate import trapezoid as trapezoid
from scipy.optimize._linesearch import line_search_wolfe1 as line_search_wolfe1, line_search_wolfe2 as line_search_wolfe2
from scipy.sparse.csgraph import laplacian as laplacian
np_version = ...
np_base_version = ...
sp_version = ...
sp_base_version = ...
CSR_CONTAINERS = ...
CSC_CONTAINERS = ...
COO_CONTAINERS = ...
LIL_CONTAINERS = ...
DOK_CONTAINERS = ...
BSR_CONTAINERS = ...
DIA_CONTAINERS = ...
SPARRAY_PRESENT: bool
SPARSE_ARRAY_PRESENT: bool
percentile = ...
class loguniform(scipy.stats.reciprocal): ...
def threadpool_limits(
limits: None | Mapping | str | int = None,
user_api: None | Literal["blas", "openmp"] = None,
) -> _ThreadpoolLimiter: ...
threadpool_limits.__doc__ = ...
def threadpool_info() -> list[dict[str, int | str] | dict[str, str | None | int]]: ...
threadpool_info.__doc__ = ...
@deprecated(
"The function `delayed` has been moved from `sklearn.utils.fixes` to "
"`sklearn.utils.parallel`. This import path will be removed in 1.5."
)
def delayed(function): ...
def pd_fillna(pd, frame): ...
def tarfile_extractall(tarfile, path) -> None: ...

Просмотреть файл

@ -28,7 +28,7 @@ from sympy.core.function import (
expand_trig,
nfloat,
)
from sympy.core.intfunc import integer_log, integer_nthroot
from sympy.core.intfunc import integer_log, integer_nthroot, num_digits, trailing
from sympy.core.kind import BooleanKind, NumberKind, UndefinedKind
from sympy.core.mod import Mod
from sympy.core.mul import Mul, prod
@ -120,6 +120,8 @@ __all__ = [
"Pow",
"integer_nthroot",
"integer_log",
"num_digits",
"trailing",
"Mul",
"prod",
"Add",

Просмотреть файл

@ -1,4 +1,3 @@
from sympy.matrices.common import NonSquareMatrixError, ShapeError
from sympy.matrices.dense import (
GramSchmidt,
MutableDenseMatrix,
@ -23,6 +22,7 @@ from sympy.matrices.dense import (
wronskian,
zeros,
)
from sympy.matrices.exceptions import NonSquareMatrixError, ShapeError
from sympy.matrices.expressions import (
Adjoint,
BlockDiagMatrix,

Просмотреть файл

@ -14,7 +14,6 @@ def smoothness(n) -> tuple[Literal[1], Literal[1]] | tuple[Any, Any]: ...
def smoothness_p(
n, m=..., power=..., visual=...
) -> str | dict[Any, Any] | tuple[Any, ...] | tuple[int, list[tuple[Any, tuple[Any, ...]]]] | LiteralString: ...
def trailing(n) -> int: ...
def multiplicity(p, n) -> int: ...
def multiplicity_in_factorial(p, n): ...
def perfect_power(n, candidates=..., big=..., factor=...): ...
@ -130,7 +129,6 @@ def mersenne_prime_exponent(
82589933,
]: ...
def is_perfect(n) -> bool | None: ...
def is_mersenne_prime(n) -> bool: ...
def abundance(n): ...
def is_abundant(n) -> bool: ...
def is_deficient(n) -> bool: ...

Просмотреть файл

@ -4,5 +4,6 @@ def mr(n, bases) -> bool: ...
def is_lucas_prp(n) -> bool: ...
def is_strong_lucas_prp(n) -> bool: ...
def is_extra_strong_lucas_prp(n) -> bool: ...
def is_mersenne_prime(n) -> bool: ...
def isprime(n) -> bool: ...
def is_gaussian_prime(num) -> bool: ...

Просмотреть файл

@ -9,7 +9,7 @@ class GMPYIntegerRing(IntegerRing):
dtype = GMPYInteger
zero = dtype(0)
one = dtype(1)
tp = type(one)
tp: type[dtype]
alias = ...
def __init__(self) -> None: ...
def to_sympy(self, a) -> Integer: ...

Просмотреть файл

@ -9,7 +9,7 @@ class GMPYRationalField(RationalField):
dtype = GMPYRational
zero = dtype(0)
one = dtype(1)
tp = type(one)
tp: type[dtype]
alias = ...
def __init__(self) -> None: ...
def get_ring(self) -> Any: ...

Просмотреть файл

@ -13,7 +13,7 @@ class IntegerRing(Ring, CharacteristicZero, SimpleDomain): # type: ignore
dtype = MPZ
zero = dtype(0)
one = dtype(1)
tp = type(one)
tp: type[dtype]
is_ZZ = ...
is_Numerical = ...
is_PID = ...

Просмотреть файл

@ -19,7 +19,7 @@ class RationalField(Field, CharacteristicZero, SimpleDomain):
dtype = MPQ
zero = dtype(0)
one = dtype(1)
tp = type(one)
tp: type[dtype]
def __init__(self) -> None: ...
def get_ring(self) -> Any: ...
def to_sympy(self, a) -> Rational | Integer: ...

Просмотреть файл

@ -1,4 +1,5 @@
#!/bin/python
from __future__ import annotations
__doc__ = """Validate Stubs.
@ -14,7 +15,6 @@ Options:
--function=<f> Restrict to the named function (or method if used with --class).
--class=<c> Restrict to the named class.
"""
from __future__ import annotations
import importlib
import importlib.machinery