Skip to content

Commit 17f1c46

Browse files
erictrautJelleZijlstraAlexWaygood
authored
Add precise values for enum members where possible (#11299)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
1 parent b3bfbef commit 17f1c46

File tree

36 files changed

+1093
-1087
lines changed

36 files changed

+1093
-1087
lines changed

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ extend-ignore = Y090
88
per-file-ignores =
99
# We should only need to noqa Y and F821 codes in .pyi files
1010
*.py: NQA
11+
# Ignore Y052 in this file: there are loads of false positives
12+
# due to the fact that flake8-pyi doesn't understand subclasses of `CoerciveEnum`
13+
# as being enum classes
14+
stubs/fpdf2/fpdf/enums.pyi: Y052
1115
# Generated protobuf files:
1216
# Y021: Include docstrings
1317
# Y023: Alias typing as typing_extensions

stdlib/asyncio/constants.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ if sys.version_info >= (3, 12):
1515
THREAD_JOIN_TIMEOUT: Literal[300]
1616

1717
class _SendfileMode(enum.Enum):
18-
UNSUPPORTED: int
19-
TRY_NATIVE: int
20-
FALLBACK: int
18+
UNSUPPORTED = 1
19+
TRY_NATIVE = 2
20+
FALLBACK = 3

stdlib/asyncio/locks.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ class BoundedSemaphore(Semaphore): ...
101101

102102
if sys.version_info >= (3, 11):
103103
class _BarrierState(enum.Enum): # undocumented
104-
FILLING: str
105-
DRAINING: str
106-
RESETTING: str
107-
BROKEN: str
104+
FILLING = "filling"
105+
DRAINING = "draining"
106+
RESETTING = "resetting"
107+
BROKEN = "broken"
108108

109109
class Barrier(_LoopBoundMixin):
110110
def __init__(self, parties: int) -> None: ...

stdlib/asyncio/sslproto.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ if sys.version_info >= (3, 11):
1414
SSLAgainErrors: tuple[type[ssl.SSLWantReadError], type[ssl.SSLSyscallError]]
1515

1616
class SSLProtocolState(Enum):
17-
UNWRAPPED: str
18-
DO_HANDSHAKE: str
19-
WRAPPED: str
20-
FLUSHING: str
21-
SHUTDOWN: str
17+
UNWRAPPED = "UNWRAPPED"
18+
DO_HANDSHAKE = "DO_HANDSHAKE"
19+
WRAPPED = "WRAPPED"
20+
FLUSHING = "FLUSHING"
21+
SHUTDOWN = "SHUTDOWN"
2222

2323
class AppProtocolState(Enum):
24-
STATE_INIT: str
25-
STATE_CON_MADE: str
26-
STATE_EOF: str
27-
STATE_CON_LOST: str
24+
STATE_INIT = "STATE_INIT"
25+
STATE_CON_MADE = "STATE_CON_MADE"
26+
STATE_EOF = "STATE_EOF"
27+
STATE_CON_LOST = "STATE_CON_LOST"
2828

2929
def add_flowcontrol_defaults(high: int | None, low: int | None, kb: int) -> tuple[int, int]: ...
3030

stdlib/http/__init__.pyi

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -15,65 +15,65 @@ class HTTPStatus(IntEnum):
1515
def phrase(self) -> str: ...
1616
@property
1717
def description(self) -> str: ...
18-
CONTINUE: int
19-
SWITCHING_PROTOCOLS: int
20-
PROCESSING: int
21-
OK: int
22-
CREATED: int
23-
ACCEPTED: int
24-
NON_AUTHORITATIVE_INFORMATION: int
25-
NO_CONTENT: int
26-
RESET_CONTENT: int
27-
PARTIAL_CONTENT: int
28-
MULTI_STATUS: int
29-
ALREADY_REPORTED: int
30-
IM_USED: int
31-
MULTIPLE_CHOICES: int
32-
MOVED_PERMANENTLY: int
33-
FOUND: int
34-
SEE_OTHER: int
35-
NOT_MODIFIED: int
36-
USE_PROXY: int
37-
TEMPORARY_REDIRECT: int
38-
PERMANENT_REDIRECT: int
39-
BAD_REQUEST: int
40-
UNAUTHORIZED: int
41-
PAYMENT_REQUIRED: int
42-
FORBIDDEN: int
43-
NOT_FOUND: int
44-
METHOD_NOT_ALLOWED: int
45-
NOT_ACCEPTABLE: int
46-
PROXY_AUTHENTICATION_REQUIRED: int
47-
REQUEST_TIMEOUT: int
48-
CONFLICT: int
49-
GONE: int
50-
LENGTH_REQUIRED: int
51-
PRECONDITION_FAILED: int
52-
REQUEST_ENTITY_TOO_LARGE: int
53-
REQUEST_URI_TOO_LONG: int
54-
UNSUPPORTED_MEDIA_TYPE: int
55-
REQUESTED_RANGE_NOT_SATISFIABLE: int
56-
EXPECTATION_FAILED: int
57-
UNPROCESSABLE_ENTITY: int
58-
LOCKED: int
59-
FAILED_DEPENDENCY: int
60-
UPGRADE_REQUIRED: int
61-
PRECONDITION_REQUIRED: int
62-
TOO_MANY_REQUESTS: int
63-
REQUEST_HEADER_FIELDS_TOO_LARGE: int
64-
INTERNAL_SERVER_ERROR: int
65-
NOT_IMPLEMENTED: int
66-
BAD_GATEWAY: int
67-
SERVICE_UNAVAILABLE: int
68-
GATEWAY_TIMEOUT: int
69-
HTTP_VERSION_NOT_SUPPORTED: int
70-
VARIANT_ALSO_NEGOTIATES: int
71-
INSUFFICIENT_STORAGE: int
72-
LOOP_DETECTED: int
73-
NOT_EXTENDED: int
74-
NETWORK_AUTHENTICATION_REQUIRED: int
75-
MISDIRECTED_REQUEST: int
76-
UNAVAILABLE_FOR_LEGAL_REASONS: int
18+
CONTINUE = 100
19+
SWITCHING_PROTOCOLS = 101
20+
PROCESSING = 102
21+
OK = 200
22+
CREATED = 201
23+
ACCEPTED = 202
24+
NON_AUTHORITATIVE_INFORMATION = 203
25+
NO_CONTENT = 204
26+
RESET_CONTENT = 205
27+
PARTIAL_CONTENT = 206
28+
MULTI_STATUS = 207
29+
ALREADY_REPORTED = 208
30+
IM_USED = 226
31+
MULTIPLE_CHOICES = 300
32+
MOVED_PERMANENTLY = 301
33+
FOUND = 302
34+
SEE_OTHER = 303
35+
NOT_MODIFIED = 304
36+
USE_PROXY = 305
37+
TEMPORARY_REDIRECT = 307
38+
PERMANENT_REDIRECT = 308
39+
BAD_REQUEST = 400
40+
UNAUTHORIZED = 401
41+
PAYMENT_REQUIRED = 402
42+
FORBIDDEN = 403
43+
NOT_FOUND = 404
44+
METHOD_NOT_ALLOWED = 405
45+
NOT_ACCEPTABLE = 406
46+
PROXY_AUTHENTICATION_REQUIRED = 407
47+
REQUEST_TIMEOUT = 408
48+
CONFLICT = 409
49+
GONE = 410
50+
LENGTH_REQUIRED = 411
51+
PRECONDITION_FAILED = 412
52+
REQUEST_ENTITY_TOO_LARGE = 413
53+
REQUEST_URI_TOO_LONG = 414
54+
UNSUPPORTED_MEDIA_TYPE = 415
55+
REQUESTED_RANGE_NOT_SATISFIABLE = 416
56+
EXPECTATION_FAILED = 417
57+
UNPROCESSABLE_ENTITY = 422
58+
LOCKED = 423
59+
FAILED_DEPENDENCY = 424
60+
UPGRADE_REQUIRED = 426
61+
PRECONDITION_REQUIRED = 428
62+
TOO_MANY_REQUESTS = 429
63+
REQUEST_HEADER_FIELDS_TOO_LARGE = 431
64+
INTERNAL_SERVER_ERROR = 500
65+
NOT_IMPLEMENTED = 501
66+
BAD_GATEWAY = 502
67+
SERVICE_UNAVAILABLE = 503
68+
GATEWAY_TIMEOUT = 504
69+
HTTP_VERSION_NOT_SUPPORTED = 505
70+
VARIANT_ALSO_NEGOTIATES = 506
71+
INSUFFICIENT_STORAGE = 507
72+
LOOP_DETECTED = 508
73+
NOT_EXTENDED = 510
74+
NETWORK_AUTHENTICATION_REQUIRED = 511
75+
MISDIRECTED_REQUEST = 421
76+
UNAVAILABLE_FOR_LEGAL_REASONS = 451
7777
if sys.version_info >= (3, 9):
7878
EARLY_HINTS: Literal[103]
7979
IM_A_TEAPOT: Literal[418]
@@ -94,12 +94,12 @@ if sys.version_info >= (3, 11):
9494
class HTTPMethod(StrEnum):
9595
@property
9696
def description(self) -> str: ...
97-
CONNECT: str
98-
DELETE: str
99-
GET: str
100-
HEAD: str
101-
OPTIONS: str
102-
PATCH: str
103-
POST: str
104-
PUT: str
105-
TRACE: str
97+
CONNECT = "CONNECT"
98+
DELETE = "DELETE"
99+
GET = "GET"
100+
HEAD = "HEAD"
101+
OPTIONS = "OPTIONS"
102+
PATCH = "PATCH"
103+
POST = "POST"
104+
PUT = "PUT"
105+
TRACE = "TRACE"

stdlib/inspect.pyi

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ if sys.version_info >= (3, 10):
347347

348348
# The name is the same as the enum's name in CPython
349349
class _ParameterKind(enum.IntEnum):
350-
POSITIONAL_ONLY: int
351-
POSITIONAL_OR_KEYWORD: int
352-
VAR_POSITIONAL: int
353-
KEYWORD_ONLY: int
354-
VAR_KEYWORD: int
350+
POSITIONAL_ONLY = 0
351+
POSITIONAL_OR_KEYWORD = 1
352+
VAR_POSITIONAL = 2
353+
KEYWORD_ONLY = 3
354+
VAR_KEYWORD = 4
355355

356356
@property
357357
def description(self) -> str: ...
@@ -611,22 +611,22 @@ if sys.version_info >= (3, 9):
611611

612612
if sys.version_info >= (3, 12):
613613
class BufferFlags(enum.IntFlag):
614-
SIMPLE: int
615-
WRITABLE: int
616-
FORMAT: int
617-
ND: int
618-
STRIDES: int
619-
C_CONTIGUOUS: int
620-
F_CONTIGUOUS: int
621-
ANY_CONTIGUOUS: int
622-
INDIRECT: int
623-
CONTIG: int
624-
CONTIG_RO: int
625-
STRIDED: int
626-
STRIDED_RO: int
627-
RECORDS: int
628-
RECORDS_RO: int
629-
FULL: int
630-
FULL_RO: int
631-
READ: int
632-
WRITE: int
614+
SIMPLE = 0
615+
WRITABLE = 1
616+
FORMAT = 4
617+
ND = 8
618+
STRIDES = 24
619+
C_CONTIGUOUS = 56
620+
F_CONTIGUOUS = 88
621+
ANY_CONTIGUOUS = 152
622+
INDIRECT = 280
623+
CONTIG = 9
624+
CONTIG_RO = 8
625+
STRIDED = 25
626+
STRIDED_RO = 24
627+
RECORDS = 29
628+
RECORDS_RO = 28
629+
FULL = 285
630+
FULL_RO = 284
631+
READ = 256
632+
WRITE = 512

stdlib/plistlib.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ if sys.version_info < (3, 9):
1111
__all__ += ["readPlist", "writePlist", "readPlistFromBytes", "writePlistToBytes", "Data"]
1212

1313
class PlistFormat(Enum):
14-
FMT_XML: int
15-
FMT_BINARY: int
14+
FMT_XML = 1
15+
FMT_BINARY = 2
1616

1717
FMT_XML = PlistFormat.FMT_XML
1818
FMT_BINARY = PlistFormat.FMT_BINARY

stdlib/pstats.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ else:
1414
_Selector: TypeAlias = str | float | int
1515

1616
class SortKey(StrEnum):
17-
CALLS: str
18-
CUMULATIVE: str
19-
FILENAME: str
20-
LINE: str
21-
NAME: str
22-
NFL: str
23-
PCALLS: str
24-
STDNAME: str
25-
TIME: str
17+
CALLS = "calls"
18+
CUMULATIVE = "cumulative"
19+
FILENAME = "filename"
20+
LINE = "line"
21+
NAME = "name"
22+
NFL = "nfl"
23+
PCALLS = "pcalls"
24+
STDNAME = "stdname"
25+
TIME = "time"
2626

2727
if sys.version_info >= (3, 9):
2828
from dataclasses import dataclass

stdlib/py_compile.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class PyCompileError(Exception):
1212
def __init__(self, exc_type: type[BaseException], exc_value: BaseException, file: str, msg: str = "") -> None: ...
1313

1414
class PycInvalidationMode(enum.Enum):
15-
TIMESTAMP: int
16-
CHECKED_HASH: int
17-
UNCHECKED_HASH: int
15+
TIMESTAMP = 1
16+
CHECKED_HASH = 2
17+
UNCHECKED_HASH = 3
1818

1919
def _get_default_invalidation_mode() -> PycInvalidationMode: ...
2020
def compile(

0 commit comments

Comments
 (0)