mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Improve enums (#3168)
I realized while working on srittau/type-stub-pep#64 that a
few things we do in existing enum definitions in typeshed are
problematic:
- Using "= ..." doesn't allow type checkers to correctly type the
result of Enum.MEMBER.value. In fact, mypy at least infers
.value to be "Ellipsis" if you do this.
- Properties on the enum values themselves, like HTTPStatus.phrase,
should not be specified directly as attributes, because it makes
type checkers think that the properties themselves are enum
members.
I ended up doing a bit more cleanup to the signal module:
- Remove unnecessary ... initializers.
- Remove unnecessary _SIG = Signals alias.
- I don't have Windows to test, but the C code for _signal suggests
that CTRL_C_EVENT and CTRL_BREAK events are not Signals, but just ints:
1dbd084f1f/Modules/signalmodule.c (L1575)
This commit is contained in:
@@ -1,67 +1,65 @@
|
||||
import sys
|
||||
|
||||
from enum import IntEnum
|
||||
|
||||
class HTTPStatus(IntEnum):
|
||||
def __init__(self, *a) -> None: ...
|
||||
@property
|
||||
def phrase(self) -> str: ...
|
||||
@property
|
||||
def description(self) -> str: ...
|
||||
|
||||
phrase: str
|
||||
description: str
|
||||
|
||||
CONTINUE = ...
|
||||
SWITCHING_PROTOCOLS = ...
|
||||
PROCESSING = ...
|
||||
OK = ...
|
||||
CREATED = ...
|
||||
ACCEPTED = ...
|
||||
NON_AUTHORITATIVE_INFORMATION = ...
|
||||
NO_CONTENT = ...
|
||||
RESET_CONTENT = ...
|
||||
PARTIAL_CONTENT = ...
|
||||
MULTI_STATUS = ...
|
||||
ALREADY_REPORTED = ...
|
||||
IM_USED = ...
|
||||
MULTIPLE_CHOICES = ...
|
||||
MOVED_PERMANENTLY = ...
|
||||
FOUND = ...
|
||||
SEE_OTHER = ...
|
||||
NOT_MODIFIED = ...
|
||||
USE_PROXY = ...
|
||||
TEMPORARY_REDIRECT = ...
|
||||
PERMANENT_REDIRECT = ...
|
||||
BAD_REQUEST = ...
|
||||
UNAUTHORIZED = ...
|
||||
PAYMENT_REQUIRED = ...
|
||||
FORBIDDEN = ...
|
||||
NOT_FOUND = ...
|
||||
METHOD_NOT_ALLOWED = ...
|
||||
NOT_ACCEPTABLE = ...
|
||||
PROXY_AUTHENTICATION_REQUIRED = ...
|
||||
REQUEST_TIMEOUT = ...
|
||||
CONFLICT = ...
|
||||
GONE = ...
|
||||
LENGTH_REQUIRED = ...
|
||||
PRECONDITION_FAILED = ...
|
||||
REQUEST_ENTITY_TOO_LARGE = ...
|
||||
REQUEST_URI_TOO_LONG = ...
|
||||
UNSUPPORTED_MEDIA_TYPE = ...
|
||||
REQUESTED_RANGE_NOT_SATISFIABLE = ...
|
||||
EXPECTATION_FAILED = ...
|
||||
UNPROCESSABLE_ENTITY = ...
|
||||
LOCKED = ...
|
||||
FAILED_DEPENDENCY = ...
|
||||
UPGRADE_REQUIRED = ...
|
||||
PRECONDITION_REQUIRED = ...
|
||||
TOO_MANY_REQUESTS = ...
|
||||
REQUEST_HEADER_FIELDS_TOO_LARGE = ...
|
||||
INTERNAL_SERVER_ERROR = ...
|
||||
NOT_IMPLEMENTED = ...
|
||||
BAD_GATEWAY = ...
|
||||
SERVICE_UNAVAILABLE = ...
|
||||
GATEWAY_TIMEOUT = ...
|
||||
HTTP_VERSION_NOT_SUPPORTED = ...
|
||||
VARIANT_ALSO_NEGOTIATES = ...
|
||||
INSUFFICIENT_STORAGE = ...
|
||||
LOOP_DETECTED = ...
|
||||
NOT_EXTENDED = ...
|
||||
NETWORK_AUTHENTICATION_REQUIRED = ...
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user