Cannot override class variable -- using Final
and ClassVar
#15616
Labels
bug
mypy got something wrong
topic-final
PEP 591
topic-inheritance
Inheritance and incompatible overrides
Bug Report
PEP 591 indicates:
But in practice, Mypy displays a type error when you use
Final
on a subclass where the parent class used aClassVar
.To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=69298f23e25b94da7dadc694769db16d
Expected Behavior
No error.
Actual Behavior
You may be tempted to work around this with:
But then Mypy outputs:
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: