Open
Description
class X:
def f(self) -> None:
pass
reveal_type(X().f)
reveal_type(X().f.__self__)
I'd expect X().f
to be some Callable
derived generic type for bound methods.
I'd expect X().f.__self__
to be typed X
. Currently __self__
is defined in the typeshed for types.MethodType
as returning object
.
Playground: https://mypy-play.net/?mypy=latest&python=3.11&gist=0de8d7a90f1d3770b3b600052c1671b1
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jorenham commentedon May 29, 2025
For what it's worth: With mypy 1.15 this is still an issue, and Pyright behaves correctly. This is also an issue for unbound methods.