Skip to content

No first-class bound method support #14235

Open
@ikonst

Description

@ikonst
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

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions