mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
exceptions: Fix AbstractEnum typing.
This will be needed for mypy 0.730. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
f1832f3e0e
commit
f25968f0ff
@@ -1,15 +1,17 @@
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, List, Type, Optional
|
||||
from typing import Any, Dict, List, Type, TypeVar, Optional
|
||||
from typing_extensions import NoReturn
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
||||
T = TypeVar("T", bound="AbstractEnum")
|
||||
|
||||
class AbstractEnum(Enum):
|
||||
'''An enumeration whose members are used strictly for their names.'''
|
||||
|
||||
def __new__(cls: Type['AbstractEnum']) -> 'AbstractEnum':
|
||||
def __new__(cls: Type[T]) -> T:
|
||||
obj = object.__new__(cls)
|
||||
obj._value_ = len(cls.__members__) + 1
|
||||
return obj
|
||||
|
||||
Reference in New Issue
Block a user