-
Notifications
You must be signed in to change notification settings - Fork 282
Closed
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations
Description
It seems that there is no way to create error-free type for Enums of primitive Python types. E.g., the following code leads to the following error: 'Item "str" of "Literal['x32'] | IWordSizeEnum32" has no attribute "value" Mypy[union-attr]'
import enum
from typing import Literal, Protocol
class IWordSizeEnum(Protocol):
@enum.property
def x32(self) -> Literal["x32"]:
...
@enum.property
def x64(self) -> Literal["x64"]:
...
@property
def name(self) -> str:
...
@property
def value(self) -> str:
...
def type_check_word_size_enum(word_size_enum: IWordSizeEnum):
word_size_enum.x32.value
Should 'Literal' add '.value' and '.name' for a 'enum.property'?
Metadata
Metadata
Assignees
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations