Skip to content

Commit 6a4075c

Browse files
calendar: fix day_name etc. type (#15738)
1 parent 551313d commit 6a4075c

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

stdlib/calendar.pyi

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import datetime
22
import enum
33
import sys
44
from _typeshed import Unused
5-
from collections.abc import Iterable, Sequence
5+
from collections.abc import Iterable
66
from time import struct_time
7-
from typing import ClassVar, Final, TypeAlias
7+
from typing import ClassVar, Final, TypeAlias, overload
88

99
__all__ = [
1010
"FRIDAY",
@@ -160,10 +160,28 @@ def formatstring(cols: Iterable[str], colwidth: int = 20, spacing: int = 6) -> s
160160
def timegm(tuple: tuple[int, ...] | struct_time) -> int: ...
161161

162162
# Data attributes
163-
day_name: Sequence[str]
164-
day_abbr: Sequence[str]
165-
month_name: Sequence[str]
166-
month_abbr: Sequence[str]
163+
class _localized_month:
164+
format: str
165+
def __init__(self, format: str) -> None: ...
166+
@overload
167+
def __getitem__(self, i: int) -> str: ...
168+
@overload
169+
def __getitem__(self, i: slice) -> list[str]: ...
170+
def __len__(self) -> int: ...
171+
172+
class _localized_day:
173+
format: str
174+
def __init__(self, format: str) -> None: ...
175+
@overload
176+
def __getitem__(self, i: int) -> str: ...
177+
@overload
178+
def __getitem__(self, i: slice) -> list[str]: ...
179+
def __len__(self) -> int: ...
180+
181+
day_name: _localized_day
182+
day_abbr: _localized_day
183+
month_name: _localized_month
184+
month_abbr: _localized_month
167185

168186
if sys.version_info >= (3, 12):
169187
class Month(enum.IntEnum):
@@ -221,5 +239,5 @@ else:
221239
EPOCH: Final = 1970
222240

223241
if sys.version_info >= (3, 15):
224-
standalone_month_name: Sequence[str]
225-
standalone_month_abbr: Sequence[str]
242+
standalone_month_name: _localized_month
243+
standalone_month_abbr: _localized_month

0 commit comments

Comments
 (0)