Skip to content

Commit 16ec7cb

Browse files
rchen152gvanrossum
authored andcommitted
Add __new__ to time.struct_time (#1394)
This is needed because otherwise pytype uses the `__new__` inherited from the `NamedTuple` base class.
1 parent 0679e02 commit 16ec7cb

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

stdlib/2/time.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class struct_time(NamedTuple('_struct_time',
1717
def __init__(self, o: Tuple[int, int, int,
1818
int, int, int,
1919
int, int, int], _arg: Any = ...) -> None: ...
20+
def __new__(cls, o: Tuple[int, int, int,
21+
int, int, int,
22+
int, int, int], _arg: Any = ...) -> struct_time: ...
2023

2124
_TIME_TUPLE = Tuple[int, int, int, int, int, int, int, int, int]
2225

stdlib/3/time.pyi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ if sys.version_info >= (3, 3):
4545
],
4646
_arg: Any = ...,
4747
) -> None: ...
48+
def __new__(
49+
cls,
50+
o: Union[
51+
Tuple[int, int, int, int, int, int, int, int, int],
52+
Tuple[int, int, int, int, int, int, int, int, int, str],
53+
Tuple[int, int, int, int, int, int, int, int, int, str, int]
54+
],
55+
_arg: Any = ...,
56+
) -> struct_time: ...
4857
else:
4958
class struct_time(
5059
NamedTuple(
@@ -55,6 +64,7 @@ else:
5564
)
5665
):
5766
def __init__(self, o: TimeTuple, _arg: Any = ...) -> None: ...
67+
def __new__(cls, o: TimeTuple, _arg: Any = ...) -> struct_time: ...
5868

5969

6070
# ----- functions -----

0 commit comments

Comments
 (0)