Closed
Description
In the program below, the type inferred for cls.g
in A.f
is Any
, even though it should be def (x: builtins.str)
:
from typing import TypeVar, Callable
T = TypeVar('T')
def dec() -> Callable[[T], T]: pass
class A:
@classmethod
def f(cls) -> None:
reveal_type(cls.g) # Any <-- unexpected
@classmethod
@dec()
def g(cls, x: str) -> None:
pass
@classmethod
def h(cls) -> None:
reveal_type(cls.g) # def (x: builtins.str) <-- ok
This works correctly when the decorated method is accessed using an instance type (such as self
).
In fine-grained incremental mode the types can be more precise, which can result in additional errors in fine-grained incremental mode.