Skip to content

Commit 24a9d25

Browse files
authored
Mypy fix all valid-type issues (#380)
1 parent 53ad216 commit 24a9d25

File tree

9 files changed

+36
-39
lines changed

9 files changed

+36
-39
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ disable_error_code = [
156156
# Since this project is specific to Pylance, just ignore them
157157
"assert-type",
158158
# TODO
159-
"valid-type", # 967 errors in 115 files
160159
"override", # 790 errors in 220 files
161160
"assignment", # 773 errors in 172 files
162161
"misc", # 692 errors in 132 files

stubs/matplotlib/_typing.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import decimal
21
import io
32
import typing_extensions
3+
from decimal import Decimal as Decimal
44

5-
import numpy.typing
65
import pandas as pd
6+
from numpy.typing import ArrayLike as ArrayLike
77

8-
Decimal = decimal.Decimal
98
PythonScalar: typing_extensions.TypeAlias = str | int | float | bool
109

11-
ArrayLike = numpy.typing.ArrayLike
1210
FileLike = io.IOBase
1311
PathLike = str
1412

stubs/matplotlib/backend_bases.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class FigureCanvasBase:
310310
def mpl_connect(self, s: str, func: Callable) -> int: ...
311311
def mpl_disconnect(self, cid: int): ...
312312
_timer_cls = TimerBase
313-
def new_timer(self, interval: int = ..., callbacks: list[tuple[Callable, tuple, dict]] = ...) -> _timer_cls: ...
313+
def new_timer(self, interval: int = ..., callbacks: list[tuple[Callable, tuple, dict]] = ...) -> TimerBase: ...
314314
def flush_events(self) -> None: ...
315315
def start_event_loop(self, timeout: int = ...) -> None: ...
316316
def stop_event_loop(self) -> None: ...

stubs/sklearn/_typing.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22
# to simplify the stubs generated by docs2stub. They are not
33
# intended to be used directly by other users.
44

5-
import decimal
65
import io
76
import typing_extensions
7+
from decimal import Decimal as Decimal
88

99
import numpy as np
10-
import numpy.typing
1110
import pandas as pd
11+
from numpy.typing import ArrayLike as ArrayLike
1212
from scipy.sparse import spmatrix
1313

1414
from .base import BaseEstimator, ClassifierMixin, RegressorMixin
1515

16-
Decimal = decimal.Decimal
1716
PythonScalar: typing_extensions.TypeAlias = str | int | float | bool
1817

19-
ArrayLike = numpy.typing.ArrayLike
2018
MatrixLike: typing_extensions.TypeAlias = np.ndarray | pd.DataFrame | spmatrix
2119
FileLike = io.IOBase
2220
PathLike = str

stubs/sympy-stubs/combinatorics/permutations.pyi

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import Generator, Iterator
1+
from collections.abc import Iterator
22
from typing import Any, Literal
33
from typing_extensions import Self
44

@@ -7,11 +7,13 @@ from sympy.core.basic import Atom
77
from sympy.core.expr import Expr
88
from sympy.core.numbers import Integer
99

10+
_List = list
11+
1012
class Cycle(dict):
1113
def __missing__(self, arg) -> int: ...
1214
def __iter__(self) -> Iterator[Any]: ...
1315
def __call__(self, *other) -> Cycle: ...
14-
def list(self, size=...) -> list[Any]: ...
16+
def list(self, size=...) -> _List[Any]: ...
1517
def __init__(self, *args) -> None: ...
1618
@property
1719
def size(self) -> Literal[0]: ...
@@ -29,12 +31,12 @@ class Permutation(Atom):
2931
def array_form(self): ...
3032
def list(self, size=...): ...
3133
@property
32-
def cyclic_form(self) -> list[Any]: ...
34+
def cyclic_form(self) -> _List[Any]: ...
3335
@property
34-
def full_cyclic_form(self) -> list[Any]: ...
36+
def full_cyclic_form(self) -> _List[Any]: ...
3537
@property
3638
def size(self) -> None: ...
37-
def support(self) -> list[int]: ...
39+
def support(self) -> _List[int]: ...
3840
def __add__(self, other) -> Self: ...
3941
def __sub__(self, other) -> Self: ...
4042
@staticmethod
@@ -46,15 +48,15 @@ class Permutation(Atom):
4648
def __mul__(self, other) -> Coset | Self: ...
4749
def commutes_with(self, other) -> bool: ...
4850
def __pow__(self, n) -> Self: ...
49-
def __rxor__(self, i) -> list[Any] | Coset | Permutation: ...
51+
def __rxor__(self, i) -> _List[Any] | Coset | Permutation: ...
5052
def __xor__(self, h) -> Self: ...
51-
def transpositions(self) -> list[Any]: ...
53+
def transpositions(self) -> _List[Any]: ...
5254
@classmethod
5355
def from_sequence(cls, i, key=...) -> Permutation: ...
5456
def __invert__(self) -> Self: ...
5557
def __iter__(self) -> Iterator[Any]: ...
5658
def __repr__(self): ...
57-
def __call__(self, *i) -> list[Any] | Coset | Self: ...
59+
def __call__(self, *i) -> _List[Any] | Coset | Self: ...
5860
def atoms(self) -> set[Any]: ...
5961
def apply(self, i) -> Integer | AppliedPermutation: ...
6062
def next_lex(self) -> Self | None: ...
@@ -78,8 +80,8 @@ class Permutation(Atom):
7880
def is_identity(self) -> bool: ...
7981
@property
8082
def is_Identity(self) -> bool: ...
81-
def ascents(self) -> list[int]: ...
82-
def descents(self) -> list[int]: ...
83+
def ascents(self) -> _List[int]: ...
84+
def descents(self) -> _List[int]: ...
8385
def max(self) -> Literal[0]: ...
8486
def min(self) -> int: ...
8587
def inversions(self) -> int: ...
@@ -92,8 +94,8 @@ class Permutation(Atom):
9294
@property
9395
def cycles(self) -> int: ...
9496
def index(self) -> int: ...
95-
def runs(self) -> list[Any]: ...
96-
def inversion_vector(self) -> list[int]: ...
97+
def runs(self) -> _List[Any]: ...
98+
def inversion_vector(self) -> _List[int]: ...
9799
def rank_trotterjohnson(self) -> int: ...
98100
@classmethod
99101
def unrank_trotterjohnson(cls, size, rank) -> Self: ...

stubs/sympy-stubs/plotting/pygletplot/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ from sympy.plotting.pygletplot.plot import PygletPlot as Plot
22
from sympy.utilities.decorator import doctest_depends_on
33

44
@doctest_depends_on(modules=("pyglet",))
5-
def PygletPlot(*args, **kwargs) -> PygletPlot: ...
5+
def PygletPlot(*args, **kwargs) -> Plot: ...

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
from typing import Any
22

33
from sympy.core.numbers import Integer
4-
from sympy.polys.domains.groundtypes import GMPYInteger, _GMPYInteger
4+
from sympy.polys.domains.groundtypes import _GMPYInteger
55
from sympy.polys.domains.integerring import IntegerRing
6-
from sympy.utilities import public
76

87
class GMPYIntegerRing(IntegerRing):
9-
dtype = GMPYInteger
10-
zero = dtype(0)
11-
one = dtype(1)
12-
tp: type[dtype]
8+
dtype = _GMPYInteger
9+
zero: _GMPYInteger
10+
one: _GMPYInteger
11+
tp: type[_GMPYInteger]
1312
alias = ...
1413
def __init__(self) -> None: ...
1514
def to_sympy(self, a) -> Integer: ...
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
from typing import Any
22

33
from sympy.core.numbers import Rational
4-
from sympy.polys.domains.groundtypes import GMPYRational, _GMPYRational
4+
from sympy.polys.domains.groundtypes import _GMPYRational
55
from sympy.polys.domains.rationalfield import RationalField
6-
from sympy.utilities import public
76

87
class GMPYRationalField(RationalField):
9-
dtype = GMPYRational
10-
zero = dtype(0)
11-
one = dtype(1)
12-
tp: type[dtype]
8+
dtype = _GMPYRational
9+
zero: _GMPYRational
10+
one: _GMPYRational
11+
tp: type[_GMPYRational]
1312
alias = ...
1413
def __init__(self) -> None: ...
1514
def get_ring(self) -> Any: ...
@@ -23,8 +22,8 @@ class GMPYRationalField(RationalField):
2322
def from_RealField(K1, a, K0) -> _GMPYRational: ...
2423
def exquo(self, a, b): ...
2524
def quo(self, a, b): ...
26-
def rem(self, a, b) -> dtype: ...
27-
def div(self, a, b) -> tuple[Any, dtype]: ...
25+
def rem(self, a, b) -> _GMPYRational: ...
26+
def div(self, a, b) -> tuple[Any, _GMPYRational]: ...
2827
def numer(self, a): ...
2928
def denom(self, a): ...
3029
def factorial(self, a) -> _GMPYRational: ...

stubs/sympy-stubs/stats/joint_rv.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Any
2-
from typing_extensions import Self
2+
from typing_extensions import Self, TypeAlias
33

44
from sympy import Basic, Equality, FiniteSet, Indexed, Integral, Ne, ProductSet, Sum
55
from sympy.core.expr import Expr
@@ -10,6 +10,8 @@ from sympy.stats.drv import ProductDiscreteDomain, SingleDiscretePSpace
1010
from sympy.stats.frv import ProductFiniteDomain
1111
from sympy.stats.rv import Distribution, NamedArgsMixin, ProductDomain, ProductPSpace as ProductPSpace, RandomSymbol, SingleDomain
1212

13+
_Set = set
14+
1315
class JointPSpace(ProductPSpace):
1416
def __new__(cls, sym, dist) -> SingleContinuousPSpace | SingleDiscretePSpace | Self: ...
1517
@property
@@ -65,7 +67,7 @@ class MarginalDistribution(Distribution):
6567
@property
6668
def set(self) -> FiniteSet | ProductSet: ...
6769
@property
68-
def symbols(self) -> set[Any]: ...
70+
def symbols(self) -> _Set[Any]: ...
6971
def pdf(self, *x) -> Basic: ...
7072
def compute_pdf(self, expr, rvs) -> Equality | Relational | Ne | Integral | Sum: ...
7173
def marginalise_out(self, expr, rv) -> Equality | Relational | Ne | Integral | Sum: ...

0 commit comments

Comments
 (0)