@@ -4135,22 +4135,34 @@ from typing import Callable, Protocol
41354135class CallbackProtocol(Protocol):
41364136 def __call__(self, __x: int) -> int: ...
41374137
4138+ class CallableObject:
4139+ attribute: str
4140+ def __call__(self, __x: int) -> int:
4141+ return 3
4142+
41384143def make_method_protocol() -> CallbackProtocol: ...
41394144def make_method_callable() -> Callable[[int], int]: ...
4145+ def make_method_object() -> CallableObject: ...
41404146
41414147class ClsProto:
41424148 meth = make_method_protocol()
41434149
41444150class ClsCall:
41454151 meth = make_method_callable()
41464152
4153+ class ClsObject:
4154+ meth = make_method_object()
4155+
41474156reveal_type(ClsProto.meth) # N: Revealed type is "__main__.CallbackProtocol"
41484157reveal_type(ClsCall.meth) # N: Revealed type is "def (builtins.int) -> builtins.int"
4158+ reveal_type(ClsObject.meth) # N: Revealed type is "__main__.CallableObject"
41494159
4150- def takes(p: ClsProto, c: ClsCall) -> None:
4160+ def takes(p: ClsProto, c: ClsCall, o: ClsObject ) -> None:
41514161 reveal_type(p.meth(0)) # E: Invalid self argument "ClsProto" to attribute function "meth" with type "Callable[[int], int]" \
41524162 # E: Too many arguments for "__call__" of "CallbackProtocol" \
41534163 # N: Revealed type is "builtins.int"
41544164 reveal_type(c.meth(0)) # E: Invalid self argument "ClsCall" to attribute function "meth" with type "Callable[[int], int]" \
41554165 # E: Too many arguments \
41564166 # N: Revealed type is "builtins.int"
4167+ reveal_type(o.meth(0)) # N: Revealed type is "builtins.int"
4168+ reveal_type(o.meth.attribute) # N: Revealed type is "builtins.str"
0 commit comments