Open
Description
Bug Report
Consider this code:
from typing import final
class A:
def __init__(self):
self._x = 4
@property
@final # E: @final should be applied only to overload implementation
def x(self) -> int:
return self._x
@x.setter
def x(self, value) -> None:
self._x = value
class B(A):
@property # E: Cannot override final attribute "x" (previously declared in base class "A")
def x(self) -> int:
return self._x
@x.setter
def x(self, value) -> None:
self._x = value
https://mypy-play.net/?mypy=latest&python=3.11&gist=a4a1981a3db4ac546b9947bb344a5fd5
Mypy complains that @final
is not applied to the "overload implementation", but the property is still successfully declared final.
I tried moving the @final
decorator to the setter – in that case, mypy's first error goes away, but then also the second error vanishes, meaning that x
wasn't actually marked as final.
(I also tried moving @final
above @property
but that produces the same result.)
Environment:
See mypy-play link above.