pyright icon indicating copy to clipboard operation
pyright copied to clipboard

Implicit override not flagged for decorated methods

Open inducer opened this issue 8 months ago • 0 comments

Describe the bug I have reportImlicitOverride=true set, and in the code below, I would expect both MySubclass.f and MySubclass.g to be flagged by this check. With pyright 1.1.403, only f gets flagged, but the (decorated) g does not.

Code or Screenshots

from typing import Callable, Concatenate, ParamSpec, TypeVar

T = TypeVar("T")
P = ParamSpec("P")
R = TypeVar("R")


def memoize_method(
        method: Callable[Concatenate[T, P], R]
        ) -> Callable[Concatenate[T, P], R]:
    return method


class MyBase:
    def f(self, x: int) -> int:
        return 2*x

    def g(self, x: int) -> int:
        return 2*x


class MySubclass(MyBase):
    def f(self, x: int) -> int:
        return 2*x

    @memoize_method
    def g(self, x: int) -> int:
        return 2*x

(Playground)

inducer avatar Jul 28 '25 20:07 inducer