Skip to content
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

🔧 stricter basedpyright config #283

Merged
merged 2 commits into from
Dec 9, 2024
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
73 changes: 45 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -193,37 +193,54 @@ stubPath = "."
pythonVersion = "3.10"
pythonPlatform = "All"
typeCheckingMode = "strict"
# ignore comments
enableTypeIgnoreComments = false
reportIgnoreCommentWithoutRule = true # based
reportUnnecessaryTypeIgnoreComment = true
# imports
reportImplicitRelativeImport = true # based
reportPrivateLocalImportUsage = false # based
reportShadowedImports = true
# classes and inheritance
reportUnsafeMultipleInheritance = true # based
reportImplicitAbstractClass = true # based
reportImplicitOverride = true
reportUnannotatedClassAttribute = true # based
# linting

deprecateTypingAliases = true
enableReachabilityAnalysis = false # discouraged
enableReachabilityAnalysis = false
enableTypeIgnoreComments = false
failOnWarnings = true # based
reportCallInDefaultInitializer = true
reportImplicitStringConcatenation = true # based
reportIgnoreCommentWithoutRule = true # based
reportImplicitAbstractClass = true # based
reportImplicitOverride = true
reportImplicitRelativeImport = true # based
reportImplicitStringConcatenation = true # based
reportImportCycles = true
reportInvalidCast = true # based
reportInvalidStubStatement = false # see execution environments
reportMissingSuperCall = true
reportPrivateLocalImportUsage = true # based
reportPrivateUsage = false
# narrowing
strictGenericNarrowing = true # based
# TODO: enable once nothing is `Untyped`
reportAny = false # based
reportExplicitAny = false # based
# environment
failOnWarnings = true # based
executionEnvironments = [
{root = "scipy-stubs", reportDeprecated = false, reportUnsafeMultipleInheritance = false, reportUnreachable = false},
{root = "codegen", reportAny = true, reportExplicitAny = true, reportInvalidCast = true, reportPrivateUsage = true},
{root = "tests", reportAny = true, reportInvalidCast = true, reportInvalidStubStatement = false},
]
reportPropertyTypeMismatch = false
reportShadowedImports = true
reportUnannotatedClassAttribute = true # based
reportUninitializedInstanceVariable = true
# reportUnnecessaryTypeIgnoreComment = false # mypy compat
reportUnnecessaryTypeIgnoreComment = true # mypy compat
strictGenericNarrowing = true # based

[[executionEnvironments]]
root = "scipy-stubs"
reportInvalidStubStatement = true
reportUnusedCallResult = true

[[executionEnvironments]]
root = "codegen"
reportAny = true # based
reportExplicitAny = true # based
reportInvalidStubStatement = true
reportPrivateUsage = true
reportUnreachable = true
reportUnsafeMultipleInheritance = true # based
reportUnusedCallResult = true

[[executionEnvironments]]
root = "tests"
reportAny = true # based
reportExplicitAny = true # based
reportPrivateUsage = true
reportUnreachable = true
reportUnsafeMultipleInheritance = true # based


[tool.repo-review]
ignore = [
Expand Down
4 changes: 2 additions & 2 deletions scipy-stubs/interpolate/interpolate.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class NdPPoly(_interpolate.NdPPoly): ...
class PPoly(_interpolate.PPoly): ...

@deprecated("will be removed in SciPy v2.0.0")
class interp1d(_interpolate.interp1d): ...
class interp1d(_interpolate.interp1d): ... # pyright: ignore[reportDeprecated]

@deprecated("will be removed in SciPy v2.0.0")
class interp2d(_interpolate.interp2d): ...
class interp2d(_interpolate.interp2d): ... # pyright: ignore[reportDeprecated]

@deprecated("will be removed in SciPy v2.0.0")
def lagrange(x: object, w: object) -> object: ...
Expand Down
2 changes: 1 addition & 1 deletion scipy-stubs/io/arff/arffread.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _msg: Final = "will be removed in SciPy v2.0.0"
class ArffError(OSError): ...

@deprecated(_msg)
class ParseArffError(ArffError): ...
class ParseArffError(ArffError): ... # pyright: ignore[reportDeprecated]

@deprecated(_msg)
class MetaData(_MetaData): ...
Expand Down
2 changes: 1 addition & 1 deletion scipy-stubs/io/matlab/mio5.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MatlabObject(np.ndarray[tuple[int, ...], np.dtype[np.generic]]):
def __new__(cls, input_array: object, classname: object = ...) -> Self: ...

@deprecated("will be removed in SciPy v2.0.0")
class MatlabFunction(MatlabObject):
class MatlabFunction(MatlabObject): # pyright: ignore[reportDeprecated]
def __new__(cls, input_array: object) -> Self: ...

@deprecated("will be removed in SciPy v2.0.0")
Expand Down
2 changes: 1 addition & 1 deletion scipy-stubs/odr/models.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ __all__ = ["Model", "exponential", "multilinear", "polynomial", "quadratic", "un
class Model(_Model): ...

@deprecated("will be removed in SciPy v2.0.0")
def polynomial(order: object) -> Model: ...
def polynomial(order: object) -> Model: ... # pyright: ignore[reportDeprecated]
4 changes: 2 additions & 2 deletions scipy-stubs/odr/odrpack.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ def odr(
full_output: int = 0,
) -> Any: ... # noqa: ANN401

odr_error = OdrError
odr_stop = OdrStop
odr_error = OdrError # pyright: ignore[reportDeprecated]
odr_stop = OdrStop # pyright: ignore[reportDeprecated]
2 changes: 1 addition & 1 deletion scipy-stubs/optimize/minpack.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def least_squares(
verbose: object = ...,
args: object = ...,
kwargs: dict[str, object] = ...,
) -> OptimizeResult: ...
) -> OptimizeResult: ... # pyright: ignore[reportDeprecated]
@deprecated("will be removed in SciPy v2.0.0")
def fsolve(
func: object,
Expand Down
28 changes: 18 additions & 10 deletions scipy-stubs/sparse/_dok.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# mypy: disable-error-code="misc, override"
# pyright: reportIncompatibleMethodOverride=false

from collections.abc import Iterable
from typing import NoReturn
from typing_extensions import Never, Self, override
Expand All @@ -9,35 +12,40 @@ from ._matrix import spmatrix

__all__ = ["dok_array", "dok_matrix", "isspmatrix_dok"]

class _dok_base(_spbase, IndexMixin, dict[tuple[int, ...], Untyped]): # type: ignore[misc] # pyright: ignore[reportIncompatibleMethodOverride]
class _dok_base(_spbase, IndexMixin, dict[tuple[int, ...], Untyped]):
dtype: Untyped
def __init__(
self, /, arg1: Untyped, shape: Untyped | None = None, dtype: Untyped | None = None, copy: bool = False
self,
/,
arg1: Untyped,
shape: Untyped | None = None,
dtype: Untyped | None = None,
copy: bool = False,
) -> None: ...
@override
def update(self, /, val: Untyped) -> None: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def update(self, /, val: Untyped) -> None: ...
@override
def setdefault(self, key: Untyped, default: Untyped | None = None, /) -> Untyped: ...
@override
def __delitem__(self, key: Untyped, /) -> None: ...
@override
def __or__(self, other: Never, /) -> NoReturn: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __or__(self, other: Never, /) -> NoReturn: ...
@override
def __ror__(self, other: Never, /) -> NoReturn: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __ror__(self, other: Never, /) -> NoReturn: ...
@override
def __ior__(self, other: Never, /) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def __ior__(self, other: Never, /) -> Self: ...
@override
def get(self, key: Untyped, /, default: float = 0.0) -> Untyped: ... # type: ignore[override]
def get(self, key: Untyped, /, default: float = 0.0) -> Untyped: ...
def conjtransp(self, /) -> Untyped: ...
@classmethod
@override
def fromkeys(cls, iterable: Iterable[tuple[int, ...]], value: int = 1, /) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def fromkeys(cls, iterable: Iterable[tuple[int, ...]], value: int = 1, /) -> Self: ...
@override
def count_nonzero(self, /) -> int: ...

class dok_array(_dok_base, sparray): ... # type: ignore[misc]
class dok_array(_dok_base, sparray): ...

class dok_matrix(spmatrix, _dok_base): # type: ignore[misc]
class dok_matrix(spmatrix, _dok_base):
@property
@override
def shape(self, /) -> tuple[int, int]: ...
Expand Down
2 changes: 1 addition & 1 deletion scipy-stubs/spatial/qhull.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ class HalfspaceIntersection(_HalfspaceIntersection): ...
class Voronoi(_Voronoi): ...

@deprecated("will be removed in SciPy v2.0.0")
def tsearch(tri: Delaunay, xi: object) -> object: ...
def tsearch(tri: _Delaunay, xi: object) -> object: ...
1 change: 1 addition & 0 deletions scipy-stubs/spatial/transform/rotation.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pyright: reportDeprecated=false
# This file is not meant for public use and will be removed in SciPy v2.0.0.

from collections.abc import Sequence
Expand Down
32 changes: 16 additions & 16 deletions scipy-stubs/special/_ufuncs.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mypy: disable-error-code="explicit-override, override"
# mypy: disable-error-code="explicit-override, override, misc"
# pyright: reportIncompatibleMethodOverride=false, reportIncompatibleVariableOverride=false

from types import EllipsisType
Expand Down Expand Up @@ -293,7 +293,7 @@ class _KwBase(TypedDict, total=False):
where: onp.ToBool | onp.ToBoolND

@type_check_only
class _UFunc(np.ufunc, Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
class _UFunc(np.ufunc, Generic[_NameT_co, _IdentityT_co]): # pyright: ignore[reportGeneralTypeIssues]
@property
@override
def __class__(self, /) -> type[np.ufunc]: ...
Expand Down Expand Up @@ -322,7 +322,7 @@ class _WithoutBinOps:
def outer(self, /, *args: object, **kwargs: object) -> Never: ...

@type_check_only
class _UFunc11(_WithoutBinOps, _UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc11(_WithoutBinOps, _UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def nin(self, /) -> L[1]: ...
Expand All @@ -334,7 +334,7 @@ class _UFunc11(_WithoutBinOps, _UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_
def nargs(self, /) -> L[2]: ...

@type_check_only
class _UFunc21(_UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc21(_UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def nin(self, /) -> L[2]: ...
Expand All @@ -346,7 +346,7 @@ class _UFunc21(_UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_c
def nargs(self, /) -> L[3]: ...

@type_check_only
class _UFunc31(_WithoutAt, _WithoutBinOps, _UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc31(_WithoutAt, _WithoutBinOps, _UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def nin(self, /) -> L[3]: ...
Expand All @@ -358,7 +358,7 @@ class _UFunc31(_WithoutAt, _WithoutBinOps, _UFunc[_NameT_co, _IdentityT_co], Gen
def nargs(self, /) -> L[4]: ...

@type_check_only
class _UFunc41(_WithoutAt, _WithoutBinOps, _UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc41(_WithoutAt, _WithoutBinOps, _UFunc[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def nin(self, /) -> L[4]: ...
Expand Down Expand Up @@ -436,7 +436,7 @@ class _Kw41f(_KwBase, TypedDict, total=False):

@final
@type_check_only
class _UFunc11f(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc11f(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[2]: ...
Expand All @@ -458,7 +458,7 @@ class _UFunc11f(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identity

@final
@type_check_only
class _UFunc11g(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc11g(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[3]: ...
Expand All @@ -480,7 +480,7 @@ class _UFunc11g(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identity

@final
@type_check_only
class _UFunc11c(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc11c(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[2]: ...
Expand All @@ -502,7 +502,7 @@ class _UFunc11c(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identity

@final
@type_check_only
class _UFunc11fc(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc11fc(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[4]: ...
Expand All @@ -528,7 +528,7 @@ class _UFunc11fc(_UFunc11[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identit

@final
@type_check_only
class _UFunc21ld(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc21ld(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[1]: ...
Expand Down Expand Up @@ -602,7 +602,7 @@ class _UFunc21ld(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identit

@final
@type_check_only
class _UFunc21f(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc21f(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[2, 3]: ...
Expand Down Expand Up @@ -762,7 +762,7 @@ class _UFunc21f(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identity

@final
@type_check_only
class _UFunc21fc1(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc21fc1(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[4, 5]: ...
Expand Down Expand Up @@ -946,7 +946,7 @@ class _UFunc21fc1(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identi

@final
@type_check_only
class _UFunc21fc2(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc21fc2(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[4]: ...
Expand Down Expand Up @@ -1206,7 +1206,7 @@ class _UFunc21fc2(_UFunc21[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identi

@final
@type_check_only
class _UFunc31f(_UFunc31[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc31f(_UFunc31[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[2, 3]: ...
Expand Down Expand Up @@ -1277,7 +1277,7 @@ class _UFunc31f(_UFunc31[_NameT_co, _IdentityT_co], Generic[_NameT_co, _Identity

@final
@type_check_only
class _UFunc41f(_UFunc41[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]): # type: ignore[misc]
class _UFunc41f(_UFunc41[_NameT_co, _IdentityT_co], Generic[_NameT_co, _IdentityT_co]):
@property
@override
def ntypes(self, /) -> L[2]: ...
Expand Down
1 change: 1 addition & 0 deletions scipy-stubs/special/orthogonal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def sh_chebyu(n: object, monic: object = ...) -> object: ...
@deprecated("will be removed in SciPy v2.0.0")
def sh_jacobi(n: object, p: object, q: object, monic: object = ...) -> object: ...

# pyright: reportDeprecated=false
p_roots = roots_legendre
t_roots = roots_chebyt
u_roots = roots_chebyu
Expand Down
2 changes: 1 addition & 1 deletion scipy-stubs/stats/_continuous_distns.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ semicircular: Final[semicircular_gen] = ...
skewcauchy: Final[skewcauchy_gen] = ...
skewnorm: Final[skewnorm_gen] = ...
trapezoid: Final[trapezoid_gen] = ...
trapz: Final[trapz_gen] = ...
trapz: Final[trapz_gen] = ... # pyright: ignore[reportDeprecated]
triang: Final[triang_gen] = ...
truncexpon: Final[truncexpon_gen] = ...
truncnorm: Final[truncnorm_gen] = ...
Expand Down
Loading
Loading