Skip to content

Mypy fix all valid-type issues #380

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

Merged
merged 1 commit into from
May 28, 2025
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
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ hygiene = ["ruff ==0.11.*"]
tests = [
# Tools used for testing
"docopt-ng",
"mypy ==1.13.*",
"mypy ==1.15.*",
"pyright",

# Typed libraries and stubs
Expand Down Expand Up @@ -156,7 +156,6 @@ disable_error_code = [
# Since this project is specific to Pylance, just ignore them
"assert-type",
# TODO
"valid-type", # 967 errors in 115 files
"override", # 790 errors in 220 files
"assignment", # 773 errors in 172 files
"misc", # 692 errors in 132 files
Expand Down
6 changes: 2 additions & 4 deletions stubs/matplotlib/_typing.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import decimal
import io
import typing_extensions
from decimal import Decimal as Decimal

import numpy.typing
import pandas as pd
from numpy.typing import ArrayLike as ArrayLike

Decimal = decimal.Decimal
PythonScalar: typing_extensions.TypeAlias = str | int | float | bool

ArrayLike = numpy.typing.ArrayLike
FileLike = io.IOBase
PathLike = str

Expand Down
2 changes: 1 addition & 1 deletion stubs/matplotlib/backend_bases.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class FigureCanvasBase:
def mpl_connect(self, s: str, func: Callable) -> int: ...
def mpl_disconnect(self, cid: int): ...
_timer_cls = TimerBase
def new_timer(self, interval: int = ..., callbacks: list[tuple[Callable, tuple, dict]] = ...) -> _timer_cls: ...
def new_timer(self, interval: int = ..., callbacks: list[tuple[Callable, tuple, dict]] = ...) -> TimerBase: ...
def flush_events(self) -> None: ...
def start_event_loop(self, timeout: int = ...) -> None: ...
def stop_event_loop(self) -> None: ...
Expand Down
6 changes: 2 additions & 4 deletions stubs/sklearn/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
# to simplify the stubs generated by docs2stub. They are not
# intended to be used directly by other users.

import decimal
import io
import typing_extensions
from decimal import Decimal as Decimal

import numpy as np
import numpy.typing
import pandas as pd
from numpy.typing import ArrayLike as ArrayLike
from scipy.sparse import spmatrix

from .base import BaseEstimator, ClassifierMixin, RegressorMixin

Decimal = decimal.Decimal
PythonScalar: typing_extensions.TypeAlias = str | int | float | bool

ArrayLike = numpy.typing.ArrayLike
MatrixLike: typing_extensions.TypeAlias = np.ndarray | pd.DataFrame | spmatrix
FileLike = io.IOBase
PathLike = str
Expand Down
26 changes: 14 additions & 12 deletions stubs/sympy-stubs/combinatorics/permutations.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections.abc import Generator, Iterator
from collections.abc import Iterator
from typing import Any, Literal
from typing_extensions import Self

Expand All @@ -7,11 +7,13 @@ from sympy.core.basic import Atom
from sympy.core.expr import Expr
from sympy.core.numbers import Integer

_List = list

class Cycle(dict):
def __missing__(self, arg) -> int: ...
def __iter__(self) -> Iterator[Any]: ...
def __call__(self, *other) -> Cycle: ...
def list(self, size=...) -> list[Any]: ...
def list(self, size=...) -> _List[Any]: ...
def __init__(self, *args) -> None: ...
@property
def size(self) -> Literal[0]: ...
Expand All @@ -29,12 +31,12 @@ class Permutation(Atom):
def array_form(self): ...
def list(self, size=...): ...
@property
def cyclic_form(self) -> list[Any]: ...
def cyclic_form(self) -> _List[Any]: ...
@property
def full_cyclic_form(self) -> list[Any]: ...
def full_cyclic_form(self) -> _List[Any]: ...
@property
def size(self) -> None: ...
def support(self) -> list[int]: ...
def support(self) -> _List[int]: ...
def __add__(self, other) -> Self: ...
def __sub__(self, other) -> Self: ...
@staticmethod
Expand All @@ -46,15 +48,15 @@ class Permutation(Atom):
def __mul__(self, other) -> Coset | Self: ...
def commutes_with(self, other) -> bool: ...
def __pow__(self, n) -> Self: ...
def __rxor__(self, i) -> list[Any] | Coset | Permutation: ...
def __rxor__(self, i) -> _List[Any] | Coset | Permutation: ...
def __xor__(self, h) -> Self: ...
def transpositions(self) -> list[Any]: ...
def transpositions(self) -> _List[Any]: ...
@classmethod
def from_sequence(cls, i, key=...) -> Permutation: ...
def __invert__(self) -> Self: ...
def __iter__(self) -> Iterator[Any]: ...
def __repr__(self): ...
def __call__(self, *i) -> list[Any] | Coset | Self: ...
def __call__(self, *i) -> _List[Any] | Coset | Self: ...
def atoms(self) -> set[Any]: ...
def apply(self, i) -> Integer | AppliedPermutation: ...
def next_lex(self) -> Self | None: ...
Expand All @@ -78,8 +80,8 @@ class Permutation(Atom):
def is_identity(self) -> bool: ...
@property
def is_Identity(self) -> bool: ...
def ascents(self) -> list[int]: ...
def descents(self) -> list[int]: ...
def ascents(self) -> _List[int]: ...
def descents(self) -> _List[int]: ...
def max(self) -> Literal[0]: ...
def min(self) -> int: ...
def inversions(self) -> int: ...
Expand All @@ -92,8 +94,8 @@ class Permutation(Atom):
@property
def cycles(self) -> int: ...
def index(self) -> int: ...
def runs(self) -> list[Any]: ...
def inversion_vector(self) -> list[int]: ...
def runs(self) -> _List[Any]: ...
def inversion_vector(self) -> _List[int]: ...
def rank_trotterjohnson(self) -> int: ...
@classmethod
def unrank_trotterjohnson(cls, size, rank) -> Self: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/sympy-stubs/plotting/pygletplot/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ from sympy.plotting.pygletplot.plot import PygletPlot as Plot
from sympy.utilities.decorator import doctest_depends_on

@doctest_depends_on(modules=("pyglet",))
def PygletPlot(*args, **kwargs) -> PygletPlot: ...
def PygletPlot(*args, **kwargs) -> Plot: ...
11 changes: 5 additions & 6 deletions stubs/sympy-stubs/polys/domains/gmpyintegerring.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from typing import Any

from sympy.core.numbers import Integer
from sympy.polys.domains.groundtypes import GMPYInteger, _GMPYInteger
from sympy.polys.domains.groundtypes import _GMPYInteger
from sympy.polys.domains.integerring import IntegerRing
from sympy.utilities import public

class GMPYIntegerRing(IntegerRing):
dtype = GMPYInteger
zero = dtype(0)
one = dtype(1)
tp: type[dtype]
dtype = _GMPYInteger
zero: _GMPYInteger
one: _GMPYInteger
tp: type[_GMPYInteger]
alias = ...
def __init__(self) -> None: ...
def to_sympy(self, a) -> Integer: ...
Expand Down
15 changes: 7 additions & 8 deletions stubs/sympy-stubs/polys/domains/gmpyrationalfield.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from typing import Any

from sympy.core.numbers import Rational
from sympy.polys.domains.groundtypes import GMPYRational, _GMPYRational
from sympy.polys.domains.groundtypes import _GMPYRational
from sympy.polys.domains.rationalfield import RationalField
from sympy.utilities import public

class GMPYRationalField(RationalField):
dtype = GMPYRational
zero = dtype(0)
one = dtype(1)
tp: type[dtype]
dtype = _GMPYRational
zero: _GMPYRational
one: _GMPYRational
tp: type[_GMPYRational]
alias = ...
def __init__(self) -> None: ...
def get_ring(self) -> Any: ...
Expand All @@ -23,8 +22,8 @@ class GMPYRationalField(RationalField):
def from_RealField(K1, a, K0) -> _GMPYRational: ...
def exquo(self, a, b): ...
def quo(self, a, b): ...
def rem(self, a, b) -> dtype: ...
def div(self, a, b) -> tuple[Any, dtype]: ...
def rem(self, a, b) -> _GMPYRational: ...
def div(self, a, b) -> tuple[Any, _GMPYRational]: ...
def numer(self, a): ...
def denom(self, a): ...
def factorial(self, a) -> _GMPYRational: ...
6 changes: 4 additions & 2 deletions stubs/sympy-stubs/stats/joint_rv.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Any
from typing_extensions import Self
from typing_extensions import Self, TypeAlias

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

_Set = set

class JointPSpace(ProductPSpace):
def __new__(cls, sym, dist) -> SingleContinuousPSpace | SingleDiscretePSpace | Self: ...
@property
Expand Down Expand Up @@ -65,7 +67,7 @@ class MarginalDistribution(Distribution):
@property
def set(self) -> FiniteSet | ProductSet: ...
@property
def symbols(self) -> set[Any]: ...
def symbols(self) -> _Set[Any]: ...
def pdf(self, *x) -> Basic: ...
def compute_pdf(self, expr, rvs) -> Equality | Relational | Ne | Integral | Sum: ...
def marginalise_out(self, expr, rv) -> Equality | Relational | Ne | Integral | Sum: ...
Expand Down