Skip to content

Commit 50077a7

Browse files
committed
no enum generic
1 parent a415ff6 commit 50077a7

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

discord/enums.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@
2727

2828
import types
2929
from enum import Enum as EnumBase
30-
from typing import TYPE_CHECKING, Any, Generic, Self, Union
31-
32-
from typing_extensions import TypeVar
30+
from typing import Any, Self, TypeVar, Union
3331

3432
E = TypeVar("E", bound="Enum")
35-
V = TypeVar("V", default=Any)
3633

3734
__all__ = (
3835
"Enum",
@@ -88,17 +85,11 @@
8885
)
8986

9087

91-
class Enum(EnumBase, Generic[V]):
88+
class Enum(EnumBase):
9289
"""An :class:`enum.Enum` subclass that implements a missing value creation behavior if it is
9390
not present in any of the members of it.
9491
"""
9592

96-
if TYPE_CHECKING:
97-
_value_: V
98-
99-
@property
100-
def value(self) -> V: ...
101-
10293
def __init_subclass__(cls, *, comparable: bool = False) -> None:
10394
super().__init_subclass__()
10495

@@ -108,8 +99,9 @@ def __init_subclass__(cls, *, comparable: bool = False) -> None:
10899
cls.__le__ = lambda self, other: isinstance(other, self.__class__) and self.value <= other.value
109100
cls.__ge__ = lambda self, other: isinstance(other, self.__class__) and self.value >= other.value
110101

102+
111103
@classmethod
112-
def _missing_(cls, value: V) -> Self:
104+
def _missing_(cls, value: Any) -> Self:
113105
name = f"unknown_{value}"
114106
if name in cls.__members__:
115107
return cls.__members__[name]

0 commit comments

Comments
 (0)