Files
django-stubs/django-stubs/db/models/enums.pyi
Étienne 574a87e68c explicitly mark value and label types on choices enum (#406)
In addition to the meta properties added
to the Choices enums, value and label are
set for each choice.
This commit explicitly types those instead of the
tuple value and non-extant label types
2020-06-22 11:08:09 +03:00

39 lines
990 B
Python

import enum
from typing import Any, List, Tuple
class ChoicesMeta(enum.EnumMeta):
names: List[str] = ...
choices: List[Tuple[Any, str]] = ...
labels: List[str] = ...
values: List[Any] = ...
def __contains__(self, item: Any) -> bool: ...
class Choices(enum.Enum, metaclass=ChoicesMeta):
def __str__(self): ...
@property
def label(self) -> str: ...
@property
def value(self) -> Any: ...
# fake
class _IntegerChoicesMeta(ChoicesMeta):
names: List[str] = ...
choices: List[Tuple[int, str]] = ...
labels: List[str] = ...
values: List[int] = ...
class IntegerChoices(int, Choices, metaclass=_IntegerChoicesMeta):
@property
def value(self) -> int: ...
# fake
class _TextChoicesMeta(ChoicesMeta):
names: List[str] = ...
choices: List[Tuple[str, str]] = ...
labels: List[str] = ...
values: List[str] = ...
class TextChoices(str, Choices, metaclass=_TextChoicesMeta):
@property
def value(self) -> str: ...