Closed
Description
Bug Report
Since __private
symbols are not shared between classes, I think we shouldn't complain if a symbol (either variable or method) that's declared Final
or @final
is redefined in a subclass. If you agree, we should probably add something to PEP 591 about this.
To Reproduce
from typing import Final, final
class Parent:
__foo: Final[int] = 0
@final
def __bar(self) -> None:
pass
class Child(Parent):
__foo: Final[int] = 1 # error: Cannot override final attribute "__foo" (previously declared in base class "Parent")
@final # error: Cannot override final attribute "__bar" (previously declared in base class "Parent")
def __bar(self) -> None:
pass
Expected Behavior
No errors.
Your Environment
- Mypy version used: 0.800+dev.37d2a5ff7a245e58af18a84e04581ccddbfb8414
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini
(and other config files): nothing - Python version used: 3.9
- Operating system and version: Windows 10