Closed as not planned
Description
Bug Report
Currently when running mypy==0.991
on a Python 3.11 file that's using StrEnum
, it errors unexpectedly on an specific named member on my code. In this case, the member only needed to be named title
to get an Incompatible types in assignment
error.
I realize python 3.11 support gh-12840 is still ongoing, but I thought I should report it to help others who might encounter this.
It might also be worth noting that it happens in older Python versions (tested on 3.10) when using strenum backport.
To Reproduce
from enum import StrEnum
class TheBug0(StrEnum):
lorem = "foo"
ipsum = "ipsum"
title = "bug0" # Bug because left side is named "title"?
class TheBug1(StrEnum):
lorem = "foo"
title = "bug1" # Bug because left side is named "title"?
ipsum = "bar"
class TheBug2(StrEnum):
title = "bug2" # Bug because left side is named "title"?
lorem = "foo"
ipsum = "bar"
class NoBug(StrEnum):
lorem = "foo"
ipsum = "bar"
Playground Gist URL: https://mypy-play.net/?mypy=latest&python=3.11&gist=910f75dbbd0c2ca484dc018a1983b654
Expected Behavior
No Errors
Actual Behavior
main.py:7: error: Incompatible types in assignment (expression has type "str", base class "str" defined the type as "Callable[[str], str]") [assignment]
main.py:12: error: Incompatible types in assignment (expression has type "str", base class "str" defined the type as "Callable[[str], str]") [assignment]
main.py:17: error: Incompatible types in assignment (expression has type "str", base class "str" defined the type as "Callable[[str], str]") [assignment]
Found 3 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used:
0.991
- Mypy command-line flags:
mypy main.py
- Mypy configuration options from
mypy.ini
(and other config files):None
- Python version used:
3.11.1