Revert "bpo-40066: [Enum] update str() and format() output (GH-30582)" (GH-30632)

This reverts commit acf7403f9b.
This commit is contained in:
Victor Stinner 2022-01-17 13:58:40 +01:00 committed by GitHub
parent 7f4b69b907
commit 42a64c03ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 2021 additions and 2087 deletions

View file

@ -2567,21 +2567,15 @@ class _empty:
class _ParameterKind(enum.IntEnum):
POSITIONAL_ONLY = 'positional-only'
POSITIONAL_OR_KEYWORD = 'positional or keyword'
VAR_POSITIONAL = 'variadic positional'
KEYWORD_ONLY = 'keyword-only'
VAR_KEYWORD = 'variadic keyword'
POSITIONAL_ONLY = 0
POSITIONAL_OR_KEYWORD = 1
VAR_POSITIONAL = 2
KEYWORD_ONLY = 3
VAR_KEYWORD = 4
def __new__(cls, description):
value = len(cls.__members__)
member = int.__new__(cls, value)
member._value_ = value
member.description = description
return member
def __str__(self):
return self.name
@property
def description(self):
return _PARAM_NAME_MAPPING[self]
_POSITIONAL_ONLY = _ParameterKind.POSITIONAL_ONLY
_POSITIONAL_OR_KEYWORD = _ParameterKind.POSITIONAL_OR_KEYWORD
@ -2589,6 +2583,14 @@ _VAR_POSITIONAL = _ParameterKind.VAR_POSITIONAL
_KEYWORD_ONLY = _ParameterKind.KEYWORD_ONLY
_VAR_KEYWORD = _ParameterKind.VAR_KEYWORD
_PARAM_NAME_MAPPING = {
_POSITIONAL_ONLY: 'positional-only',
_POSITIONAL_OR_KEYWORD: 'positional or keyword',
_VAR_POSITIONAL: 'variadic positional',
_KEYWORD_ONLY: 'keyword-only',
_VAR_KEYWORD: 'variadic keyword'
}
class Parameter:
"""Represents a parameter in a function signature.