Use typing_extensions.Self instead of _typeshed.Self (#9702)

This commit is contained in:
Alex Waygood
2023-02-15 11:32:43 +01:00
committed by GitHub
parent 8cd6d81f15
commit 7180d0223b
140 changed files with 597 additions and 610 deletions

View File

@@ -1,8 +1,8 @@
from _typeshed import Self
from typing_extensions import Self
class weekday:
def __init__(self, weekday: int, n: int | None = ...) -> None: ...
def __call__(self: Self, n: int) -> Self: ...
def __call__(self, n: int) -> Self: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
weekday: int

View File

@@ -1,12 +1,9 @@
from _typeshed import Self
from datetime import date, datetime, timedelta
from typing import SupportsFloat, TypeVar, overload
from typing_extensions import TypeAlias
from typing_extensions import Self, TypeAlias
from ._common import weekday
# We need the extra "Self" TypeVar to avoid overlapping __add__/__radd__ complaints from mypy
_SelfT = TypeVar("_SelfT", bound=relativedelta)
_DateT = TypeVar("_DateT", date, datetime)
# Work around attribute and type having the same name.
_Weekday: TypeAlias = weekday
@@ -64,36 +61,36 @@ class relativedelta:
def weeks(self) -> int: ...
@weeks.setter
def weeks(self, value: int) -> None: ...
def normalized(self: Self) -> Self: ...
def normalized(self) -> Self: ...
# TODO: use Union when mypy will handle it properly in overloaded operator
# methods (#2129, #1442, #1264 in mypy)
@overload
def __add__(self: _SelfT, other: relativedelta) -> _SelfT: ... # noqa: Y019
def __add__(self, other: relativedelta) -> Self: ...
@overload
def __add__(self: _SelfT, other: timedelta) -> _SelfT: ... # noqa: Y019
def __add__(self, other: timedelta) -> Self: ...
@overload
def __add__(self, other: _DateT) -> _DateT: ...
@overload
def __radd__(self: _SelfT, other: relativedelta) -> _SelfT: ... # noqa: Y019
def __radd__(self, other: relativedelta) -> Self: ...
@overload
def __radd__(self: _SelfT, other: timedelta) -> _SelfT: ... # noqa: Y019
def __radd__(self, other: timedelta) -> Self: ...
@overload
def __radd__(self, other: _DateT) -> _DateT: ...
@overload
def __rsub__(self: Self, other: relativedelta) -> Self: ...
def __rsub__(self, other: relativedelta) -> Self: ...
@overload
def __rsub__(self: Self, other: timedelta) -> Self: ...
def __rsub__(self, other: timedelta) -> Self: ...
@overload
def __rsub__(self, other: _DateT) -> _DateT: ...
def __sub__(self: Self, other: relativedelta) -> Self: ...
def __neg__(self: Self) -> Self: ...
def __sub__(self, other: relativedelta) -> Self: ...
def __neg__(self) -> Self: ...
def __bool__(self) -> bool: ...
def __nonzero__(self) -> bool: ...
def __mul__(self: Self, other: SupportsFloat) -> Self: ...
def __rmul__(self: Self, other: SupportsFloat) -> Self: ...
def __mul__(self, other: SupportsFloat) -> Self: ...
def __rmul__(self, other: SupportsFloat) -> Self: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __div__(self: Self, other: SupportsFloat) -> Self: ...
def __truediv__(self: Self, other: SupportsFloat) -> Self: ...
def __abs__(self: Self) -> Self: ...
def __div__(self, other: SupportsFloat) -> Self: ...
def __truediv__(self, other: SupportsFloat) -> Self: ...
def __abs__(self) -> Self: ...
def __hash__(self) -> int: ...