Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add precise values for enum members where possible #11299

Merged
merged 39 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9bb03d0
Changed enums to conform with proposed change to typing spec discusse…
erictraut Jan 22, 2024
2c63836
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
ce2f1ba
Fixed some of the problems stubtest found.
erictraut Jan 22, 2024
1447bf9
Merge branch 'enum-type-change' of https://github.com/erictraut/types…
erictraut Jan 22, 2024
e7df031
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
44ea4d1
Fixed more issues found by stubtest
erictraut Jan 22, 2024
42f5f81
Merge branch 'enum-type-change' of https://github.com/erictraut/types…
erictraut Jan 22, 2024
76030ba
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
0de299b
More fixes from tests
erictraut Jan 22, 2024
9a8eafe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
71be421
More fixes from test results
erictraut Jan 22, 2024
ed15ebd
More fixes
erictraut Jan 22, 2024
4c84746
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
16f4971
Tests really didn't like that change
erictraut Jan 22, 2024
f3de805
Merge branch 'enum-type-change' of https://github.com/erictraut/types…
erictraut Jan 22, 2024
6253c04
Merge branch 'main' into enum-type-change
JelleZijlstra Mar 9, 2024
9be0c58
Merge branch 'main' of https://github.com/python/typeshed into enum-t…
erictraut Apr 10, 2024
18480de
Added missing enum values to recently-added stubs.
erictraut Apr 10, 2024
1e54df7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2024
4819fe2
Addressed another stubtest failure.
erictraut Apr 10, 2024
2aeb508
Merge branch 'enum-type-change' of https://github.com/erictraut/types…
erictraut Apr 10, 2024
56560c2
Silenced a pyright error.
erictraut Apr 10, 2024
0748e23
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2024
79d034d
Trying to make stubtest happy.
erictraut Apr 10, 2024
be000b0
Merge branch 'enum-type-change' of https://github.com/erictraut/types…
erictraut Apr 10, 2024
a66fb38
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2024
4aef83b
fix pre-commit errors
AlexWaygood Apr 11, 2024
e0f8e84
make sure it's Final constants being assigned in the psutil enum
AlexWaygood Apr 11, 2024
db11c8e
Merge branch 'main' into enum-type-change
AlexWaygood Apr 11, 2024
e4ab75c
Update .flake8
AlexWaygood Apr 11, 2024
bd170fa
Address issue with unknown integer values for platform-specific butto…
erictraut Apr 13, 2024
71684a8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 13, 2024
762439d
Added literal values for linux-specific button enums.
erictraut Apr 14, 2024
413b303
Merge branch 'enum-type-change' of https://github.com/erictraut/types…
erictraut Apr 14, 2024
18c0111
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 14, 2024
fb0a2c4
unknown is 0 according to stubtest
JelleZijlstra Apr 15, 2024
129de9e
deal with Key enum
JelleZijlstra Apr 15, 2024
843d4ad
Everything is an alias for alt
JelleZijlstra Apr 15, 2024
279a068
Make the requested changes
AlexWaygood Apr 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ per-file-ignores =
*.py: NQA
# TODO: Remove bare "Incomplete"s from stubs (Y065)
*.pyi: Y065
# Ignore Y052 in this file: there are loads of false positives
# due to the fact that flake8-pyi doesn't understand subclasses of `CoerciveEnum`
# as being enum classes
stubs/fpdf2/fpdf/enums.pyi: Y052, Y065
srittau marked this conversation as resolved.
Show resolved Hide resolved
# Generated protobuf files:
# Y021: Include docstrings
# Y023: Alias typing as typing_extensions
Expand Down
6 changes: 3 additions & 3 deletions stdlib/asyncio/constants.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ if sys.version_info >= (3, 12):
THREAD_JOIN_TIMEOUT: Literal[300]

class _SendfileMode(enum.Enum):
UNSUPPORTED: int
TRY_NATIVE: int
FALLBACK: int
UNSUPPORTED = 1
TRY_NATIVE = 2
FALLBACK = 3
8 changes: 4 additions & 4 deletions stdlib/asyncio/locks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class BoundedSemaphore(Semaphore): ...

if sys.version_info >= (3, 11):
class _BarrierState(enum.Enum): # undocumented
FILLING: str
DRAINING: str
RESETTING: str
BROKEN: str
FILLING = "filling"
DRAINING = "draining"
RESETTING = "resetting"
BROKEN = "broken"

class Barrier(_LoopBoundMixin):
def __init__(self, parties: int) -> None: ...
Expand Down
18 changes: 9 additions & 9 deletions stdlib/asyncio/sslproto.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ if sys.version_info >= (3, 11):
SSLAgainErrors: tuple[type[ssl.SSLWantReadError], type[ssl.SSLSyscallError]]

class SSLProtocolState(Enum):
UNWRAPPED: str
DO_HANDSHAKE: str
WRAPPED: str
FLUSHING: str
SHUTDOWN: str
UNWRAPPED = "UNWRAPPED"
DO_HANDSHAKE = "DO_HANDSHAKE"
WRAPPED = "WRAPPED"
FLUSHING = "FLUSHING"
SHUTDOWN = "SHUTDOWN"

class AppProtocolState(Enum):
STATE_INIT: str
STATE_CON_MADE: str
STATE_EOF: str
STATE_CON_LOST: str
STATE_INIT = "STATE_INIT"
STATE_CON_MADE = "STATE_CON_MADE"
STATE_EOF = "STATE_EOF"
STATE_CON_LOST = "STATE_CON_LOST"

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

Expand Down
136 changes: 68 additions & 68 deletions stdlib/http/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,65 +15,65 @@ class HTTPStatus(IntEnum):
def phrase(self) -> str: ...
@property
def description(self) -> str: ...
CONTINUE: int
SWITCHING_PROTOCOLS: int
PROCESSING: int
OK: int
CREATED: int
ACCEPTED: int
NON_AUTHORITATIVE_INFORMATION: int
NO_CONTENT: int
RESET_CONTENT: int
PARTIAL_CONTENT: int
MULTI_STATUS: int
ALREADY_REPORTED: int
IM_USED: int
MULTIPLE_CHOICES: int
MOVED_PERMANENTLY: int
FOUND: int
SEE_OTHER: int
NOT_MODIFIED: int
USE_PROXY: int
TEMPORARY_REDIRECT: int
PERMANENT_REDIRECT: int
BAD_REQUEST: int
UNAUTHORIZED: int
PAYMENT_REQUIRED: int
FORBIDDEN: int
NOT_FOUND: int
METHOD_NOT_ALLOWED: int
NOT_ACCEPTABLE: int
PROXY_AUTHENTICATION_REQUIRED: int
REQUEST_TIMEOUT: int
CONFLICT: int
GONE: int
LENGTH_REQUIRED: int
PRECONDITION_FAILED: int
REQUEST_ENTITY_TOO_LARGE: int
REQUEST_URI_TOO_LONG: int
UNSUPPORTED_MEDIA_TYPE: int
REQUESTED_RANGE_NOT_SATISFIABLE: int
EXPECTATION_FAILED: int
UNPROCESSABLE_ENTITY: int
LOCKED: int
FAILED_DEPENDENCY: int
UPGRADE_REQUIRED: int
PRECONDITION_REQUIRED: int
TOO_MANY_REQUESTS: int
REQUEST_HEADER_FIELDS_TOO_LARGE: int
INTERNAL_SERVER_ERROR: int
NOT_IMPLEMENTED: int
BAD_GATEWAY: int
SERVICE_UNAVAILABLE: int
GATEWAY_TIMEOUT: int
HTTP_VERSION_NOT_SUPPORTED: int
VARIANT_ALSO_NEGOTIATES: int
INSUFFICIENT_STORAGE: int
LOOP_DETECTED: int
NOT_EXTENDED: int
NETWORK_AUTHENTICATION_REQUIRED: int
MISDIRECTED_REQUEST: int
UNAVAILABLE_FOR_LEGAL_REASONS: int
CONTINUE = 100
SWITCHING_PROTOCOLS = 101
PROCESSING = 102
OK = 200
CREATED = 201
ACCEPTED = 202
NON_AUTHORITATIVE_INFORMATION = 203
NO_CONTENT = 204
RESET_CONTENT = 205
PARTIAL_CONTENT = 206
MULTI_STATUS = 207
ALREADY_REPORTED = 208
IM_USED = 226
MULTIPLE_CHOICES = 300
MOVED_PERMANENTLY = 301
FOUND = 302
SEE_OTHER = 303
NOT_MODIFIED = 304
USE_PROXY = 305
TEMPORARY_REDIRECT = 307
PERMANENT_REDIRECT = 308
BAD_REQUEST = 400
UNAUTHORIZED = 401
PAYMENT_REQUIRED = 402
FORBIDDEN = 403
NOT_FOUND = 404
METHOD_NOT_ALLOWED = 405
NOT_ACCEPTABLE = 406
PROXY_AUTHENTICATION_REQUIRED = 407
REQUEST_TIMEOUT = 408
CONFLICT = 409
GONE = 410
LENGTH_REQUIRED = 411
PRECONDITION_FAILED = 412
REQUEST_ENTITY_TOO_LARGE = 413
REQUEST_URI_TOO_LONG = 414
UNSUPPORTED_MEDIA_TYPE = 415
REQUESTED_RANGE_NOT_SATISFIABLE = 416
EXPECTATION_FAILED = 417
UNPROCESSABLE_ENTITY = 422
LOCKED = 423
FAILED_DEPENDENCY = 424
UPGRADE_REQUIRED = 426
PRECONDITION_REQUIRED = 428
TOO_MANY_REQUESTS = 429
REQUEST_HEADER_FIELDS_TOO_LARGE = 431
INTERNAL_SERVER_ERROR = 500
NOT_IMPLEMENTED = 501
BAD_GATEWAY = 502
SERVICE_UNAVAILABLE = 503
GATEWAY_TIMEOUT = 504
HTTP_VERSION_NOT_SUPPORTED = 505
VARIANT_ALSO_NEGOTIATES = 506
INSUFFICIENT_STORAGE = 507
LOOP_DETECTED = 508
NOT_EXTENDED = 510
NETWORK_AUTHENTICATION_REQUIRED = 511
MISDIRECTED_REQUEST = 421
UNAVAILABLE_FOR_LEGAL_REASONS = 451
if sys.version_info >= (3, 9):
EARLY_HINTS: Literal[103]
IM_A_TEAPOT: Literal[418]
Expand All @@ -94,12 +94,12 @@ if sys.version_info >= (3, 11):
class HTTPMethod(StrEnum):
@property
def description(self) -> str: ...
CONNECT: str
DELETE: str
GET: str
HEAD: str
OPTIONS: str
PATCH: str
POST: str
PUT: str
TRACE: str
CONNECT = "CONNECT"
DELETE = "DELETE"
GET = "GET"
HEAD = "HEAD"
OPTIONS = "OPTIONS"
PATCH = "PATCH"
POST = "POST"
PUT = "PUT"
TRACE = "TRACE"
48 changes: 24 additions & 24 deletions stdlib/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ if sys.version_info >= (3, 10):

# The name is the same as the enum's name in CPython
class _ParameterKind(enum.IntEnum):
POSITIONAL_ONLY: int
POSITIONAL_OR_KEYWORD: int
VAR_POSITIONAL: int
KEYWORD_ONLY: int
VAR_KEYWORD: int
POSITIONAL_ONLY = 0
POSITIONAL_OR_KEYWORD = 1
VAR_POSITIONAL = 2
KEYWORD_ONLY = 3
VAR_KEYWORD = 4

@property
def description(self) -> str: ...
Expand Down Expand Up @@ -611,22 +611,22 @@ if sys.version_info >= (3, 9):

if sys.version_info >= (3, 12):
class BufferFlags(enum.IntFlag):
SIMPLE: int
WRITABLE: int
FORMAT: int
ND: int
STRIDES: int
C_CONTIGUOUS: int
F_CONTIGUOUS: int
ANY_CONTIGUOUS: int
INDIRECT: int
CONTIG: int
CONTIG_RO: int
STRIDED: int
STRIDED_RO: int
RECORDS: int
RECORDS_RO: int
FULL: int
FULL_RO: int
READ: int
WRITE: int
SIMPLE = 0
WRITABLE = 1
FORMAT = 4
ND = 8
STRIDES = 24
C_CONTIGUOUS = 56
F_CONTIGUOUS = 88
ANY_CONTIGUOUS = 152
INDIRECT = 280
CONTIG = 9
CONTIG_RO = 8
STRIDED = 25
STRIDED_RO = 24
RECORDS = 29
RECORDS_RO = 28
FULL = 285
FULL_RO = 284
READ = 256
WRITE = 512
4 changes: 2 additions & 2 deletions stdlib/plistlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ if sys.version_info < (3, 9):
__all__ += ["readPlist", "writePlist", "readPlistFromBytes", "writePlistToBytes", "Data"]

class PlistFormat(Enum):
FMT_XML: int
FMT_BINARY: int
FMT_XML = 1
FMT_BINARY = 2

FMT_XML = PlistFormat.FMT_XML
FMT_BINARY = PlistFormat.FMT_BINARY
Expand Down
18 changes: 9 additions & 9 deletions stdlib/pstats.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ else:
_Selector: TypeAlias = str | float | int

class SortKey(StrEnum):
CALLS: str
CUMULATIVE: str
FILENAME: str
LINE: str
NAME: str
NFL: str
PCALLS: str
STDNAME: str
TIME: str
CALLS = "calls"
CUMULATIVE = "cumulative"
FILENAME = "filename"
LINE = "line"
NAME = "name"
NFL = "nfl"
PCALLS = "pcalls"
STDNAME = "stdname"
TIME = "time"

if sys.version_info >= (3, 9):
from dataclasses import dataclass
Expand Down
6 changes: 3 additions & 3 deletions stdlib/py_compile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class PyCompileError(Exception):
def __init__(self, exc_type: type[BaseException], exc_value: BaseException, file: str, msg: str = "") -> None: ...

class PycInvalidationMode(enum.Enum):
TIMESTAMP: int
CHECKED_HASH: int
UNCHECKED_HASH: int
TIMESTAMP = 1
CHECKED_HASH = 2
UNCHECKED_HASH = 3

def _get_default_invalidation_mode() -> PycInvalidationMode: ...
def compile(
Expand Down