From 81701a0a73579bf44c1a0103fe18ee16712e2ade Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 6 Jun 2023 21:22:24 +0300 Subject: [PATCH 1/2] Update calendar.pyi for Python3.12 --- stdlib/calendar.pyi | 75 ++++++++++++++++++++++++++--- tests/stubtest_allowlists/py312.txt | 15 ------ 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 255a12d3348a..6e466910e5a0 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -1,4 +1,5 @@ import datetime +import enum import sys from _typeshed import Unused from collections.abc import Iterable, Sequence @@ -35,6 +36,21 @@ __all__ = [ if sys.version_info >= (3, 10): __all__ += ["FRIDAY", "MONDAY", "SATURDAY", "SUNDAY", "THURSDAY", "TUESDAY", "WEDNESDAY"] +if sys.version_info >= (3, 12): + __all__ += [ + "Month", + "JANUARY", "FEBRUARY", "MARCH", + "APRIL", "MAY", "JUNE", "JULY", + "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER", + "Day", + "MONDAY", + "TUESDAY", + "WEDNESDAY", + "THURSDAY", + "FRIDAY", + "SATURDAY", + "SUNDAY", + ] _LocaleType: TypeAlias = tuple[str | None, str | None] @@ -134,12 +150,57 @@ day_abbr: Sequence[str] month_name: Sequence[str] month_abbr: Sequence[str] -MONDAY: Literal[0] -TUESDAY: Literal[1] -WEDNESDAY: Literal[2] -THURSDAY: Literal[3] -FRIDAY: Literal[4] -SATURDAY: Literal[5] -SUNDAY: Literal[6] +if sys.version_info >= (3, 12): + class Month(enum.IntEnum): + JANUARY: Literal[1] + FEBRUARY: Literal[2] + MARCH: Literal[3] + APRIL: Literal[4] + MAY: Literal[5] + JUNE: Literal[6] + JULY: Literal[7] + AUGUST: Literal[8] + SEPTEMBER: Literal[9] + OCTOBER: Literal[10] + NOVEMBER: Literal[11] + DECEMBER: Literal[12] + + JANUARY = Month.JANUARY + FEBRUARY = Month.FEBRUARY + MARCH = Month.MARCH + APRIL = Month.APRIL + MAY = Month.MAY + JUNE = Month.JUNE + JULY = Month.JULY + AUGUST = Month.AUGUST + SEPTEMBER = Month.SEPTEMBER + OCTOBER = Month.OCTOBER + NOVEMBER = Month.NOVEMBER + DECEMBER = Month.DECEMBER + + class Day(enum.IntEnum): + MONDAY: Literal[0] + TUESDAY: Literal[1] + WEDNESDAY: Literal[2] + THURSDAY: Literal[3] + FRIDAY: Literal[4] + SATURDAY: Literal[5] + SUNDAY: Literal[6] + + MONDAY = Day.MONDAY + TUESDAY = Day.TUESDAY + WEDNESDAY = Day.WEDNESDAY + THURSDAY = Day.THURSDAY + FRIDAY = Day.FRIDAY + SATURDAY = Day.SATURDAY + SUNDAY = Day.SUNDAY +else: + MONDAY: Literal[0] + TUESDAY: Literal[1] + WEDNESDAY: Literal[2] + THURSDAY: Literal[3] + FRIDAY: Literal[4] + SATURDAY: Literal[5] + SUNDAY: Literal[6] EPOCH: Literal[1970] diff --git a/tests/stubtest_allowlists/py312.txt b/tests/stubtest_allowlists/py312.txt index 6cbf66ac1273..eaff9e6d9717 100644 --- a/tests/stubtest_allowlists/py312.txt +++ b/tests/stubtest_allowlists/py312.txt @@ -19,21 +19,6 @@ asyncio.tasks.Task.get_context asyncio.tasks.__all__ asyncio.tasks.create_eager_task_factory asyncio.tasks.eager_task_factory -calendar.APRIL -calendar.AUGUST -calendar.DECEMBER -calendar.Day -calendar.FEBRUARY -calendar.JANUARY -calendar.JULY -calendar.JUNE -calendar.MARCH -calendar.MAY -calendar.Month -calendar.NOVEMBER -calendar.OCTOBER -calendar.SEPTEMBER -calendar.__all__ collections.UserDict.get configparser.ParsingError.__init__ configparser.RawConfigParser.readfp From f4b0ee5532c07403d8189357957f93ec73d6ea03 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Jun 2023 18:24:55 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/calendar.pyi | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/stdlib/calendar.pyi b/stdlib/calendar.pyi index 6e466910e5a0..68d91d8519a9 100644 --- a/stdlib/calendar.pyi +++ b/stdlib/calendar.pyi @@ -39,9 +39,18 @@ if sys.version_info >= (3, 10): if sys.version_info >= (3, 12): __all__ += [ "Month", - "JANUARY", "FEBRUARY", "MARCH", - "APRIL", "MAY", "JUNE", "JULY", - "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER", + "JANUARY", + "FEBRUARY", + "MARCH", + "APRIL", + "MAY", + "JUNE", + "JULY", + "AUGUST", + "SEPTEMBER", + "OCTOBER", + "NOVEMBER", + "DECEMBER", "Day", "MONDAY", "TUESDAY", @@ -164,7 +173,6 @@ if sys.version_info >= (3, 12): OCTOBER: Literal[10] NOVEMBER: Literal[11] DECEMBER: Literal[12] - JANUARY = Month.JANUARY FEBRUARY = Month.FEBRUARY MARCH = Month.MARCH @@ -186,7 +194,6 @@ if sys.version_info >= (3, 12): FRIDAY: Literal[4] SATURDAY: Literal[5] SUNDAY: Literal[6] - MONDAY = Day.MONDAY TUESDAY = Day.TUESDAY WEDNESDAY = Day.WEDNESDAY