Skip to content

Commit b94c0be

Browse files
authored
🏷️ fix stubtest errors in numpy.polynomial.chebyshev (#255)
1 parent 0d40128 commit b94c0be

File tree

4 files changed

+808
-194
lines changed

4 files changed

+808
-194
lines changed

src/numpy-stubs/polynomial/_polytypes.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ from typing import (
44
Literal as L,
55
Protocol,
66
SupportsIndex as CanIndex,
7-
SupportsInt,
7+
SupportsInt as CanInt,
88
TypeAlias,
99
overload,
1010
type_check_only,
@@ -50,27 +50,26 @@ from _numtype import (
5050
from numpy._typing import _NestedSequence, _NumberLike_co
5151

5252
_T = TypeVar("_T")
53-
_T_contra = TypeVar("_T_contra", contravariant=True, default=Any)
5453
_CoefT = TypeVar("_CoefT", bound=np.number | np.bool | np.object_)
5554
_NameT_co = TypeVar("_NameT_co", bound=str, default=LiteralString, covariant=True)
5655

5756
# compatible with e.g. int, float, complex, Decimal, Fraction, and ABCPolyBase
5857
@type_check_only
59-
class _SupportsCoefOps(Protocol[_T_contra]):
58+
class _SupportsCoefOps(Protocol):
6059
def __eq__(self, x: object, /) -> bool: ...
6160
def __ne__(self, x: object, /) -> bool: ...
6261
def __neg__(self, /) -> Self: ...
6362
def __pos__(self, /) -> Self: ...
64-
def __add__(self, x: _T_contra, /) -> Self: ...
65-
def __sub__(self, x: _T_contra, /) -> Self: ...
66-
def __mul__(self, x: _T_contra, /) -> Self: ...
67-
def __pow__(self, x: _T_contra, /) -> Self | float: ...
68-
def __radd__(self, x: _T_contra, /) -> Self: ...
69-
def __rsub__(self, x: _T_contra, /) -> Self: ...
70-
def __rmul__(self, x: _T_contra, /) -> Self: ...
63+
def __add__(self, x: Any, /) -> Self: ...
64+
def __sub__(self, x: Any, /) -> Self: ...
65+
def __mul__(self, x: Any, /) -> Self: ...
66+
def __pow__(self, x: Any, /) -> Self | float: ...
67+
def __radd__(self, x: Any, /) -> Self: ...
68+
def __rsub__(self, x: Any, /) -> Self: ...
69+
def __rmul__(self, x: Any, /) -> Self: ...
7170

7271
_Tuple2: TypeAlias = tuple[_T, _T]
73-
_ToInt: TypeAlias = SupportsInt | CanIndex
72+
_ToInt: TypeAlias = CanInt | CanIndex
7473

7574
_InexactObject_1d: TypeAlias = Array_1d[np.inexact | np.object_]
7675
_InexactObject_nd: TypeAlias = Array[np.inexact | np.object_]
@@ -85,6 +84,11 @@ _ToNumeric_nd: TypeAlias = _ToArray_nd[np.number | np.bool | np.object_, complex
8584
_ToValF: TypeAlias = Callable[[Array[Any], Array[Any], bool], _ToNumeric_nd]
8685
_ToVanderF: TypeAlias = Callable[[Array[Any], int], _ToNumericObject_nd]
8786

87+
_Indices: TypeAlias = Sequence[CanIndex]
88+
89+
_FullFitResult: TypeAlias = Sequence[np.inexact | np.int32]
90+
_ArrayAndFitResult: TypeAlias = tuple[Array[_CoefT], _FullFitResult]
91+
8892
@type_check_only
8993
class _HasName(Protocol[_NameT_co]):
9094
@property
@@ -396,8 +400,6 @@ class _FuncVander(_HasName[_NameT_co], Protocol[_NameT_co]):
396400
@overload
397401
def __call__(self, /, x: npt.ArrayLike, deg: CanIndex) -> Array[Any]: ...
398402

399-
_Indices: TypeAlias = Sequence[CanIndex]
400-
401403
@type_check_only
402404
class _FuncVander2D(_HasName[_NameT_co], Protocol[_NameT_co]):
403405
@overload
@@ -469,8 +471,6 @@ class _FuncVanderND(_HasName[_NameT_co], Protocol[_NameT_co]):
469471
degrees: Sequence[CanIndex],
470472
) -> Array[Any]: ...
471473

472-
_FullFitResult: TypeAlias = Sequence[np.inexact | np.int32]
473-
474474
@type_check_only
475475
class _FuncFit(_HasName[_NameT_co], Protocol[_NameT_co]):
476476
@overload

0 commit comments

Comments
 (0)