mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-30 16:14:24 +08:00
Python3.8 additions and changes (#3337)
* Add as_integer_ratio() to a few types * Add dirs_exist_ok to copytree() * int, float, complex accept __index__ args Also fix complex.__init__ argument names * Add __reversed__ to dict et al. * Python 3.8 date(time) arithmetic fixes * Add CodeType.replace()
This commit is contained in:
committed by
Jelle Zijlstra
parent
d0beab9b8e
commit
8a7d61741d
@@ -17,6 +17,11 @@ import sys
|
||||
if sys.version_info >= (3,):
|
||||
from typing import SupportsBytes, SupportsRound
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
else:
|
||||
from typing_extensions import Literal
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T_co = TypeVar('_T_co', covariant=True)
|
||||
_KT = TypeVar('_KT')
|
||||
@@ -29,6 +34,9 @@ _T4 = TypeVar('_T4')
|
||||
_T5 = TypeVar('_T5')
|
||||
_TT = TypeVar('_TT', bound='type')
|
||||
|
||||
class _SupportsIndex(Protocol):
|
||||
def __index__(self) -> int: ...
|
||||
|
||||
class object:
|
||||
__doc__: Optional[str]
|
||||
__dict__: Dict[str, Any]
|
||||
@@ -129,10 +137,12 @@ class super(object):
|
||||
|
||||
class int:
|
||||
@overload
|
||||
def __init__(self, x: Union[Text, bytes, SupportsInt] = ...) -> None: ...
|
||||
def __init__(self, x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, x: Union[Text, bytes, bytearray], base: int) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ...
|
||||
@property
|
||||
def real(self) -> int: ...
|
||||
@property
|
||||
@@ -209,7 +219,7 @@ class int:
|
||||
def __index__(self) -> int: ...
|
||||
|
||||
class float:
|
||||
def __init__(self, x: Union[SupportsFloat, Text, bytes, bytearray] = ...) -> None: ...
|
||||
def __init__(self, x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> None: ...
|
||||
def as_integer_ratio(self) -> Tuple[int, int]: ...
|
||||
def hex(self) -> str: ...
|
||||
def is_integer(self) -> bool: ...
|
||||
@@ -271,11 +281,9 @@ class float:
|
||||
|
||||
class complex:
|
||||
@overload
|
||||
def __init__(self, re: float = ..., im: float = ...) -> None: ...
|
||||
def __init__(self, real: float = ..., imag: float = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(self, s: str) -> None: ...
|
||||
@overload
|
||||
def __init__(self, s: SupportsComplex) -> None: ...
|
||||
def __init__(self, real: Union[str, SupportsComplex, _SupportsIndex]) -> None: ...
|
||||
|
||||
@property
|
||||
def real(self) -> float: ...
|
||||
@@ -987,6 +995,8 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __setitem__(self, k: _KT, v: _VT) -> None: ...
|
||||
def __delitem__(self, v: _KT) -> None: ...
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def __reversed__(self) -> Iterator[_KT]: ...
|
||||
def __str__(self) -> str: ...
|
||||
__hash__: None # type: ignore
|
||||
|
||||
@@ -1117,8 +1127,6 @@ if sys.version_info < (3,):
|
||||
if sys.version_info >= (3,):
|
||||
def ascii(__o: object) -> str: ...
|
||||
|
||||
class _SupportsIndex(Protocol):
|
||||
def __index__(self) -> int: ...
|
||||
def bin(__number: Union[int, _SupportsIndex]) -> str: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
|
||||
Reference in New Issue
Block a user