Skip to content

Commit 2419d75

Browse files
authored
Improve datetime._IsoCalendarDate (#13029)
1 parent 68d0520 commit 2419d75

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

stdlib/datetime.pyi

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from abc import abstractmethod
33
from time import struct_time
4-
from typing import ClassVar, Final, NamedTuple, NoReturn, SupportsIndex, final, overload
4+
from typing import ClassVar, Final, NoReturn, SupportsIndex, final, overload, type_check_only
55
from typing_extensions import Self, TypeAlias, deprecated
66

77
if sys.version_info >= (3, 11):
@@ -40,10 +40,17 @@ if sys.version_info >= (3, 11):
4040
UTC: timezone
4141

4242
if sys.version_info >= (3, 9):
43-
class _IsoCalendarDate(NamedTuple):
44-
year: int
45-
week: int
46-
weekday: int
43+
# This class calls itself datetime.IsoCalendarDate. It's neither
44+
# NamedTuple nor structseq.
45+
@final
46+
@type_check_only
47+
class _IsoCalendarDate(tuple[int, int, int]):
48+
@property
49+
def year(self) -> int: ...
50+
@property
51+
def week(self) -> int: ...
52+
@property
53+
def weekday(self) -> int: ...
4754

4855
class date:
4956
min: ClassVar[date]

0 commit comments

Comments
 (0)