mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-25 01:38:40 +08:00
Use _typeshed.Self in Python 2, too (#6932)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from abc import ABCMeta
|
||||
from typing import Any, Dict, Iterator, List, Mapping, Type, TypeVar, Union
|
||||
|
||||
@@ -59,15 +60,15 @@ class Flag(Enum):
|
||||
def __repr__(self) -> str: ...
|
||||
def __str__(self) -> str: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
def __or__(self: _T, other: _T) -> _T: ...
|
||||
def __and__(self: _T, other: _T) -> _T: ...
|
||||
def __xor__(self: _T, other: _T) -> _T: ...
|
||||
def __invert__(self: _T) -> _T: ...
|
||||
def __or__(self: Self, other: Self) -> Self: ...
|
||||
def __and__(self: Self, other: Self) -> Self: ...
|
||||
def __xor__(self: Self, other: Self) -> Self: ...
|
||||
def __invert__(self: Self) -> Self: ...
|
||||
|
||||
class IntFlag(int, Flag):
|
||||
def __or__(self: _T, other: Union[int, _T]) -> _T: ...
|
||||
def __and__(self: _T, other: Union[int, _T]) -> _T: ...
|
||||
def __xor__(self: _T, other: Union[int, _T]) -> _T: ...
|
||||
def __or__(self: Self, other: Union[int, Self]) -> Self: ...
|
||||
def __and__(self: Self, other: Union[int, Self]) -> Self: ...
|
||||
def __xor__(self: Self, other: Union[int, Self]) -> Self: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import threading
|
||||
from _typeshed import Self
|
||||
from abc import abstractmethod
|
||||
from logging import Logger
|
||||
from types import TracebackType
|
||||
@@ -48,7 +49,7 @@ class Executor:
|
||||
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
|
||||
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...) -> Iterator[_T]: ...
|
||||
def shutdown(self, wait: bool = ...) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Optional[bool]: ...
|
||||
|
||||
def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Container, Generic, Iterable, Iterator, Optional, SupportsInt, Text, Tuple, TypeVar, overload
|
||||
|
||||
# Undocumented length constants
|
||||
@@ -30,10 +31,10 @@ class _IPAddressBase:
|
||||
|
||||
class _BaseAddress(_IPAddressBase, SupportsInt):
|
||||
def __init__(self, address: object) -> None: ...
|
||||
def __add__(self: _T, other: int) -> _T: ...
|
||||
def __add__(self: Self, other: int) -> Self: ...
|
||||
def __hash__(self) -> int: ...
|
||||
def __int__(self) -> int: ...
|
||||
def __sub__(self: _T, other: int) -> _T: ...
|
||||
def __sub__(self: Self, other: int) -> Self: ...
|
||||
@property
|
||||
def is_global(self) -> bool: ...
|
||||
@property
|
||||
@@ -87,7 +88,7 @@ class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]):
|
||||
@property
|
||||
def prefixlen(self) -> int: ...
|
||||
def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ...
|
||||
def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ...
|
||||
def supernet(self: Self, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Self: ...
|
||||
@property
|
||||
def with_hostmask(self) -> Text: ...
|
||||
@property
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from _typeshed import Self
|
||||
from datetime import date, datetime, timedelta
|
||||
from typing import SupportsFloat, TypeVar, overload
|
||||
|
||||
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.
|
||||
@@ -61,37 +63,37 @@ class relativedelta(object):
|
||||
def weeks(self) -> int: ...
|
||||
@weeks.setter
|
||||
def weeks(self, value: int) -> None: ...
|
||||
def normalized(self: _SelfT) -> _SelfT: ...
|
||||
def normalized(self: 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: ...
|
||||
def __add__(self: _SelfT, other: relativedelta) -> _SelfT: ... # noqa: Y019
|
||||
@overload
|
||||
def __add__(self: _SelfT, other: timedelta) -> _SelfT: ...
|
||||
def __add__(self: _SelfT, other: timedelta) -> _SelfT: ... # noqa: Y019
|
||||
@overload
|
||||
def __add__(self, other: _DateT) -> _DateT: ...
|
||||
@overload
|
||||
def __radd__(self: _SelfT, other: relativedelta) -> _SelfT: ...
|
||||
def __radd__(self: _SelfT, other: relativedelta) -> _SelfT: ... # noqa: Y019
|
||||
@overload
|
||||
def __radd__(self: _SelfT, other: timedelta) -> _SelfT: ...
|
||||
def __radd__(self: _SelfT, other: timedelta) -> _SelfT: ... # noqa: Y019
|
||||
@overload
|
||||
def __radd__(self, other: _DateT) -> _DateT: ...
|
||||
@overload
|
||||
def __rsub__(self: _SelfT, other: relativedelta) -> _SelfT: ...
|
||||
def __rsub__(self: Self, other: relativedelta) -> Self: ...
|
||||
@overload
|
||||
def __rsub__(self: _SelfT, other: timedelta) -> _SelfT: ...
|
||||
def __rsub__(self: Self, other: timedelta) -> Self: ...
|
||||
@overload
|
||||
def __rsub__(self, other: _DateT) -> _DateT: ...
|
||||
def __sub__(self: _SelfT, other: relativedelta) -> _SelfT: ...
|
||||
def __neg__(self: _SelfT) -> _SelfT: ...
|
||||
def __sub__(self: Self, other: relativedelta) -> Self: ...
|
||||
def __neg__(self: Self) -> Self: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
def __nonzero__(self) -> bool: ...
|
||||
def __mul__(self: _SelfT, other: SupportsFloat) -> _SelfT: ...
|
||||
def __rmul__(self: _SelfT, other: SupportsFloat) -> _SelfT: ...
|
||||
def __mul__(self: Self, other: SupportsFloat) -> Self: ...
|
||||
def __rmul__(self: Self, other: SupportsFloat) -> Self: ...
|
||||
def __eq__(self, other: object) -> bool: ...
|
||||
def __ne__(self, other: object) -> bool: ...
|
||||
def __div__(self: _SelfT, other: SupportsFloat) -> _SelfT: ...
|
||||
def __truediv__(self: _SelfT, other: SupportsFloat) -> _SelfT: ...
|
||||
def __div__(self: Self, other: SupportsFloat) -> Self: ...
|
||||
def __truediv__(self: Self, other: SupportsFloat) -> Self: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __abs__(self: _SelfT) -> _SelfT: ...
|
||||
def __abs__(self: Self) -> Self: ...
|
||||
def __hash__(self) -> int: ...
|
||||
|
||||
Reference in New Issue
Block a user