Bug Report
On python 3.11 using StrEnum, if converting given enum to a list and assigning to a variable, mypy will wrongly assumes that given variable will be list[str], not list[StrEnum].
To Reproduce
fromenumimportStrEnumclassChoices(StrEnum):
LOREM="lorem"IPSUM="ipsum"# This is okdefok_func() ->list[Choices]:
returnlist(Choices)
# However this produces an errordeferror_func() ->list[Choices]:
var=list(Choices)
returnvar
https://mypy-play.net/?mypy=latest&python=3.11&gist=e73a15c8902092236567da4a4567f372
Expected Behavior
Mypy should assume list[Choices] type for var.
Actual Behavior
Incompatible return value type (got "List[str]", expected "List[Choices]") [return-value]
Your Environment
- Mypy version used: 1.0.0
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini (and other config files): none - Python version used: 3.11.1
Bug Report
On python 3.11 using StrEnum, if converting given enum to a list and assigning to a variable, mypy will wrongly assumes that given variable will be
list[str], notlist[StrEnum].To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=e73a15c8902092236567da4a4567f372
Expected Behavior
Mypy should assume
list[Choices]type forvar.Actual Behavior
Incompatible return value type (got "List[str]", expected "List[Choices]") [return-value]Your Environment
mypy.ini(and other config files): none