-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
Bug Report
Mypy, at least versions 1.17.1 and the latest 1.19.1 incorrectly classifies private members as Enum members and tags them as final.
But, since Python 3.11, private members are not enum members, see https://docs.python.org/3/howto/enum.html#private-names
To Reproduce
https://mypy-play.net/?gist=afd9e4e68abe69277d97eb42f33adbcf
from typing import ClassVar
from enum import IntEnum
class WithDocReference:
_doc_reference: ClassVar[str]
class MyEnum(WithDocReference, IntEnum):
_doc_reference = "https://www.google.com"
A = 1
B = 2
Expected Behavior
Type checks without error.
Actual Behavior
mypy 1.17.1 fails with
$ mypy test.py
test.py:8: error: Cannot override writable attribute "_doc_reference" with a final one [misc]
Found 1 error in 1 file (checked 1 source file)
mypy 1.19.1 has an additional error.
Your Environment
- Mypy version used: 1.17.1 and 1.19.1
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.11.9
Reactions are currently unavailable