Skip to content

Commit 16ca92f

Browse files
authored
Add http.HTTPMethod (#7784)
python/cpython#91997 `description` isn't actually read-only at runtime, but I don't think there's any other way of telling type checkers "this is an attribute that the members have, not a member itself". And pretending it's a property is already what we do for `HTTPStatus`, which has the same issue.
1 parent 031c998 commit 16ca92f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

stdlib/http/__init__.pyi

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import sys
22
from enum import IntEnum
33
from typing_extensions import Literal
44

5-
__all__ = ["HTTPStatus"]
5+
if sys.version_info >= (3, 11):
6+
from enum import StrEnum
7+
8+
if sys.version_info >= (3, 11):
9+
__all__ = ["HTTPStatus", "HTTPMethod"]
10+
else:
11+
__all__ = ["HTTPStatus"]
612

713
class HTTPStatus(IntEnum):
814
@property
@@ -74,3 +80,17 @@ class HTTPStatus(IntEnum):
7480
EARLY_HINTS: Literal[103]
7581
IM_A_TEAPOT: Literal[418]
7682
TOO_EARLY: Literal[425]
83+
84+
if sys.version_info >= (3, 11):
85+
class HTTPMethod(StrEnum):
86+
@property
87+
def description(self) -> str: ...
88+
CONNECT: str
89+
DELETE: str
90+
GET: str
91+
HEAD: str
92+
OPTIONS: str
93+
PATCH: str
94+
POST: str
95+
PUT: str
96+
TRACE: str

0 commit comments

Comments
 (0)