mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Add TimeTuple in python3's time.pyi and datetime.pyi. (#597)
Add `TimeTuple = Tuple[int, int, int, int, int, int, int, int, int]` to stdlib/3/time.pyi and stdlib/3/datetime.pyi. Use `TimeTuple` instead of `tuple` (where relevant) in time.pyi for stronger type checking. Use `TimeTuple` instead of `Tuple[int, int, int, int, int, int, int, int, int]` in datetime.pyi to increase readability.
This commit is contained in:
committed by
Matthias Kramm
parent
b0eae4bf46
commit
b92991bc2a
@@ -7,6 +7,8 @@ from typing import Optional, SupportsAbs, Tuple, overload
|
||||
MINYEAR = 0
|
||||
MAXYEAR = 0
|
||||
|
||||
TimeTuple = Tuple[int, int, int, int, int, int, int, int, int]
|
||||
|
||||
class tzinfo:
|
||||
def tzname(self, dt: Optional[datetime]) -> str: ...
|
||||
def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ...
|
||||
@@ -189,9 +191,9 @@ class datetime:
|
||||
def strftime(self, fmt: str) -> str: ...
|
||||
def __format__(self, fmt: str) -> str: ...
|
||||
def toordinal(self) -> int: ...
|
||||
def timetuple(self) -> tuple: ... # TODO return type
|
||||
def timetuple(self) -> TimeTuple: ... # TODO return type
|
||||
def timestamp(self) -> float: ...
|
||||
def utctimetuple(self) -> tuple: ... # TODO return type
|
||||
def utctimetuple(self) -> TimeTuple: ... # TODO return type
|
||||
def date(self) -> _date: ...
|
||||
def time(self) -> _time: ...
|
||||
def timetz(self) -> _time: ...
|
||||
|
||||
@@ -8,6 +8,8 @@ import sys
|
||||
from typing import Tuple, Union
|
||||
from types import SimpleNamespace
|
||||
|
||||
TimeTuple = Tuple[int, int, int, int, int, int, int, int, int]
|
||||
|
||||
# ----- variables and constants -----
|
||||
accept2dyear = False
|
||||
altzone = 0
|
||||
@@ -47,21 +49,15 @@ class struct_time:
|
||||
tm_zone = 'GMT'
|
||||
|
||||
# ----- functions -----
|
||||
def asctime(t: Union[Tuple[int, int, int, int, int, int, int, int, int],
|
||||
struct_time,
|
||||
None] = ...) -> str: ... # return current time
|
||||
def asctime(t: Union[TimeTuple, struct_time, None] = ...) -> str: ... # return current time
|
||||
def clock() -> float: ...
|
||||
def ctime(secs: Union[float, None] = ...) -> str: ... # return current time
|
||||
def gmtime(secs: Union[float, None] = ...) -> struct_time: ... # return current time
|
||||
def localtime(secs: Union[float, None] = ...) -> struct_time: ... # return current time
|
||||
def mktime(t: Union[Tuple[int, int, int, int, int,
|
||||
int, int, int, int],
|
||||
struct_time]) -> float: ...
|
||||
def mktime(t: Union[TimeTuple, struct_time]) -> float: ...
|
||||
def sleep(secs: Union[int, float]) -> None: ...
|
||||
def strftime(format: str, t: Union[Tuple[int, int, int, int, int,
|
||||
int, int, int, int],
|
||||
struct_time,
|
||||
None] = ...) -> str: ... # return current time
|
||||
def strftime(format: str,
|
||||
t: Union[TimeTuple, struct_time, None] = ...) -> str: ... # return current time
|
||||
def strptime(string: str,
|
||||
format: str = ...) -> struct_time: ...
|
||||
def time() -> float: ...
|
||||
|
||||
Reference in New Issue
Block a user