basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

no error when using `@final` decorator on a method in a `Protocol`

Open DetachHead opened this issue 1 year ago • 1 comments

Code sample in basedpyright playground

from typing import Protocol, final, override


class Foo(Protocol):
    @final
    def foo(self): ...

class Bar(Foo):
    @override
    def foo(self): # error: can't override foo
        ...

class Baz(Foo): ... # error: didn't implement foo

DetachHead avatar Feb 12 '25 08:02 DetachHead

note that this is "implementing" the protocol not "extending" it, which is different, see https://github.com/DetachHead/basedpyright/issues/294#issuecomment-2611489040

DetachHead avatar Apr 07 '25 01:04 DetachHead