mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-28 14:46:55 +08:00
Merge Python 2 and 3 versions of time.pyi (#1909)
* Use variable annotations * Replace default values by ellipses * Remove exceptions from function bodies * Remove superfluous comments * Remove superfluous newlines * Use Optional instead of Union[..., None] * Replace Union[int, float] by just float * Make time.pyi (Python 2) more closely resemble the Python 3 stub * Replace _TIME_TUPLE by TimeTuple * Reorder imports * time.pyi: Mark two arguments as optional, mark Unix-only function * time.pyi (Python 2): Use TimeTuple in NamedTuple and reformat This makes time.pyi more closely match the Python3 version. * Merge Python 2 and 3 versions of time.pyi * Only import SimpleNamespace on Python >= 3.3 * Remove default values from module properties * Remove Optional from strftime() and asctime() * accept2dyear was removed in Python 3.3 * Rename TimeTuple to _TimeTuple
This commit is contained in:
committed by
Jelle Zijlstra
parent
35d3effe03
commit
38aea73b4b
@@ -1,54 +0,0 @@
|
||||
"""Stub file for the 'time' module."""
|
||||
# See https://docs.python.org/2/library/time.html
|
||||
|
||||
from typing import NamedTuple, Tuple, Union, Any, Optional
|
||||
|
||||
# ----- variables and constants -----
|
||||
accept2dyear = False
|
||||
altzone = 0
|
||||
daylight = 0
|
||||
timezone = 0
|
||||
tzname = ... # type: Tuple[str, str]
|
||||
|
||||
class struct_time(NamedTuple('_struct_time',
|
||||
[('tm_year', int), ('tm_mon', int), ('tm_mday', int),
|
||||
('tm_hour', int), ('tm_min', int), ('tm_sec', int),
|
||||
('tm_wday', int), ('tm_yday', int), ('tm_isdst', int)])):
|
||||
def __init__(self, o: Tuple[int, int, int,
|
||||
int, int, int,
|
||||
int, int, int], _arg: Any = ...) -> None: ...
|
||||
def __new__(cls, o: Tuple[int, int, int,
|
||||
int, int, int,
|
||||
int, int, int], _arg: Any = ...) -> struct_time: ...
|
||||
|
||||
_TIME_TUPLE = Tuple[int, int, int, int, int, int, int, int, int]
|
||||
|
||||
def asctime(t: Union[struct_time, _TIME_TUPLE] = ...) -> str:
|
||||
raise ValueError()
|
||||
|
||||
def clock() -> float: ...
|
||||
|
||||
def ctime(secs: Optional[float] = ...) -> str:
|
||||
raise ValueError()
|
||||
|
||||
def gmtime(secs: Optional[float] = ...) -> struct_time: ...
|
||||
|
||||
def localtime(secs: Optional[float] = ...) -> struct_time: ...
|
||||
|
||||
def mktime(t: Union[struct_time, _TIME_TUPLE]) -> float:
|
||||
raise OverflowError()
|
||||
raise ValueError()
|
||||
|
||||
def sleep(secs: float) -> None: ...
|
||||
|
||||
def strftime(format: str, t: Union[struct_time, _TIME_TUPLE] = ...) -> str:
|
||||
raise MemoryError()
|
||||
raise ValueError()
|
||||
|
||||
def strptime(string: str, format: str = ...) -> struct_time:
|
||||
raise ValueError()
|
||||
|
||||
def time() -> float:
|
||||
raise IOError()
|
||||
|
||||
def tzset() -> None: ...
|
||||
Reference in New Issue
Block a user