-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Enum value with a trailing comma is reported as a 1-tuple, but it's str and runtime.
class BodyType1(str, Enum):
Text = "text",
Html = "html",
class BodyType2(str, Enum):
Text = "text"
Html = "html"
body_type_1: str = BodyType1.Text.value
body_type_2: str = BodyType2.Text.value
print(type(body_type_1))
print(type(body_type_2))The BodyType example is taken from Graph SDK https://github.com/microsoftgraph/msgraph-sdk-python/blob/main/msgraph/generated/models/body_type.py
To my knowledge values separated with comma will all be passed to init (https://docs.python.org/3/library/enum.html#enum.Enum.__init__).
Here Text = "text", should be equivalent to str("text",).
$ pyright --version
pyright 1.1.408
$ pyright test.py
error: Type "tuple[Literal['text']]" is not assignable to declared type "str"
"tuple[Literal['text']]" is not assignable to "str" (reportAssignmentType)
$ python --version
Python 3.13.7
$ python test.py
<class 'str'>
<class 'str'>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working