In the program below, the type inferred for cls.g in A.f is Any, even though it should be def (x: builtins.str):
fromtypingimportTypeVar, CallableT=TypeVar('T')
defdec() ->Callable[[T], T]: passclassA:
@classmethoddeff(cls) ->None:
reveal_type(cls.g) # Any <-- unexpected@classmethod@dec()defg(cls, x: str) ->None:
pass@classmethoddefh(cls) ->None:
reveal_type(cls.g) # def (x: builtins.str) <-- okThis 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.
In the program below, the type inferred for
cls.ginA.fisAny, even though it should bedef (x: builtins.str):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.