Skip to content

Commit

Permalink
stdlib: fix some enum definitions (#11956)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdanal committed May 18, 2024
1 parent 8bd6ceb commit b570af5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
58 changes: 29 additions & 29 deletions stdlib/calendar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sys
from _typeshed import Unused
from collections.abc import Iterable, Sequence
from time import struct_time
from typing import ClassVar, Literal
from typing import ClassVar, Final
from typing_extensions import TypeAlias

__all__ = [
Expand Down Expand Up @@ -154,18 +154,18 @@ month_abbr: Sequence[str]

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 = 1
FEBRUARY = 2
MARCH = 3
APRIL = 4
MAY = 5
JUNE = 6
JULY = 7
AUGUST = 8
SEPTEMBER = 9
OCTOBER = 10
NOVEMBER = 11
DECEMBER = 12

JANUARY = Month.JANUARY
FEBRUARY = Month.FEBRUARY
Expand All @@ -181,13 +181,13 @@ if sys.version_info >= (3, 12):
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 = 0
TUESDAY = 1
WEDNESDAY = 2
THURSDAY = 3
FRIDAY = 4
SATURDAY = 5
SUNDAY = 6

MONDAY = Day.MONDAY
TUESDAY = Day.TUESDAY
Expand All @@ -197,12 +197,12 @@ if sys.version_info >= (3, 12):
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]
MONDAY: Final = 0
TUESDAY: Final = 1
WEDNESDAY: Final = 2
THURSDAY: Final = 3
FRIDAY: Final = 4
SATURDAY: Final = 5
SUNDAY: Final = 6

EPOCH: Final = 1970
7 changes: 3 additions & 4 deletions stdlib/http/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
from enum import IntEnum
from typing import Literal

if sys.version_info >= (3, 11):
from enum import StrEnum
Expand Down Expand Up @@ -75,9 +74,9 @@ class HTTPStatus(IntEnum):
MISDIRECTED_REQUEST = 421
UNAVAILABLE_FOR_LEGAL_REASONS = 451
if sys.version_info >= (3, 9):
EARLY_HINTS: Literal[103]
IM_A_TEAPOT: Literal[418]
TOO_EARLY: Literal[425]
EARLY_HINTS = 103
IM_A_TEAPOT = 418
TOO_EARLY = 425
if sys.version_info >= (3, 12):
@property
def is_informational(self) -> bool: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/re.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class RegexFlag(enum.IntFlag):
T = sre_compile.SRE_FLAG_TEMPLATE
TEMPLATE = T
if sys.version_info >= (3, 11):
NOFLAG: int
NOFLAG = 0

A = RegexFlag.A
ASCII = RegexFlag.ASCII
Expand Down

0 comments on commit b570af5

Please sign in to comment.