Add a structseq class to _typeshed (#6560)

Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
Alex Waygood
2021-12-17 21:42:09 +00:00
committed by GitHub
parent 183a43a7e0
commit 0b75d71303
16 changed files with 301 additions and 254 deletions

View File

@@ -1,6 +1,7 @@
import sys
from _typeshed import structseq
from types import SimpleNamespace
from typing import Any, NamedTuple, Tuple
from typing import Any, Tuple, Union
from typing_extensions import final
_TimeTuple = Tuple[int, int, int, int, int, int, int, int, int]
@@ -32,39 +33,31 @@ if sys.version_info >= (3, 8) and sys.platform == "darwin":
if sys.version_info >= (3, 9) and sys.platform == "linux":
CLOCK_TAI: int
class _struct_time(NamedTuple):
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
@property
def n_fields(self) -> int: ...
@property
def n_sequence_fields(self) -> int: ...
@property
def n_unnamed_fields(self) -> int: ...
# Constructor takes an iterable of any type, of length between 9 and 11 elements.
# However, it always *behaves* like a tuple of 9 elements,
# even if an iterable with length >9 is passed.
# https://github.com/python/typeshed/pull/6560#discussion_r767162532
@final
class struct_time(_struct_time):
def __init__(
self,
o: tuple[int, int, int, int, int, int, int, int, int]
| tuple[int, int, int, int, int, int, int, int, int, str]
| tuple[int, int, int, int, int, int, int, int, int, str, int],
_arg: Any = ...,
) -> None: ...
def __new__(
cls,
o: tuple[int, int, int, int, int, int, int, int, int]
| tuple[int, int, int, int, int, int, int, int, int, str]
| tuple[int, int, int, int, int, int, int, int, int, str, int],
_arg: Any = ...,
) -> struct_time: ...
class struct_time(structseq[Union[Any, int]], _TimeTuple):
@property
def tm_year(self) -> int: ...
@property
def tm_mon(self) -> int: ...
@property
def tm_mday(self) -> int: ...
@property
def tm_hour(self) -> int: ...
@property
def tm_min(self) -> int: ...
@property
def tm_sec(self) -> int: ...
@property
def tm_wday(self) -> int: ...
@property
def tm_yday(self) -> int: ...
@property
def tm_isdst(self) -> int: ...
# These final two properties only exist if a 10- or 11-item sequence was passed to the constructor.
@property
def tm_zone(self) -> str: ...
@property