mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-19 01:22:51 +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
@@ -1,9 +1,8 @@
|
||||
import sys
|
||||
from time import struct_time
|
||||
from typing import (
|
||||
AnyStr, Optional, SupportsAbs, Tuple, Union, overload,
|
||||
ClassVar,
|
||||
)
|
||||
from typing import AnyStr, Optional, SupportsAbs, Tuple, Union, overload, ClassVar, Type, TypeVar
|
||||
|
||||
_S = TypeVar("_S")
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
_Text = str
|
||||
@@ -68,7 +67,10 @@ class date:
|
||||
def __lt__(self, other: date) -> bool: ...
|
||||
def __ge__(self, other: date) -> bool: ...
|
||||
def __gt__(self, other: date) -> bool: ...
|
||||
def __add__(self, other: timedelta) -> date: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def __add__(self: _S, other: timedelta) -> _S: ...
|
||||
else:
|
||||
def __add__(self, other: timedelta) -> date: ...
|
||||
@overload
|
||||
def __sub__(self, other: timedelta) -> date: ...
|
||||
@overload
|
||||
@@ -227,8 +229,16 @@ class datetime(date):
|
||||
def today(cls) -> datetime: ...
|
||||
@classmethod
|
||||
def fromordinal(cls, n: int) -> datetime: ...
|
||||
@classmethod
|
||||
def now(cls, tz: Optional[_tzinfo] = ...) -> datetime: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
@classmethod
|
||||
def now(cls: Type[_S], tz: Optional[_tzinfo] = ...) -> _S: ...
|
||||
else:
|
||||
@overload
|
||||
@classmethod
|
||||
def now(cls: Type[_S], tz: None = ...) -> _S: ...
|
||||
@overload
|
||||
@classmethod
|
||||
def now(cls, tz: _tzinfo) -> datetime: ...
|
||||
@classmethod
|
||||
def utcnow(cls) -> datetime: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
@@ -261,7 +271,9 @@ class datetime(date):
|
||||
def replace(self, year: int = ..., month: int = ..., day: int = ..., hour: int = ...,
|
||||
minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo:
|
||||
Optional[_tzinfo] = ...) -> datetime: ...
|
||||
if sys.version_info >= (3, 3):
|
||||
if sys.version_info >= (3, 8):
|
||||
def astimezone(self: _S, tz: Optional[_tzinfo] = ...) -> _S: ...
|
||||
elif sys.version_info >= (3, 3):
|
||||
def astimezone(self, tz: Optional[_tzinfo] = ...) -> datetime: ...
|
||||
else:
|
||||
def astimezone(self, tz: _tzinfo) -> datetime: ...
|
||||
@@ -279,7 +291,10 @@ class datetime(date):
|
||||
def __lt__(self, other: datetime) -> bool: ... # type: ignore
|
||||
def __ge__(self, other: datetime) -> bool: ... # type: ignore
|
||||
def __gt__(self, other: datetime) -> bool: ... # type: ignore
|
||||
def __add__(self, other: timedelta) -> datetime: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def __add__(self: _S, other: timedelta) -> _S: ...
|
||||
else:
|
||||
def __add__(self, other: timedelta) -> datetime: ...
|
||||
@overload # type: ignore
|
||||
def __sub__(self, other: datetime) -> timedelta: ...
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user