Skip to content

Callable vs Protocol with self argument #21599

@Mercerenies

Description

@Mercerenies

Bug Report

mypy seems to be unwilling to bind self to a decorated method if the method's return type is declared as a Protocol with __call__, but is willing to do so if the return type is Callable. See the example below.

To Reproduce

https://mypy-play.net/?gist=2fb651ddee58d4176237eb3c3dfb7c1a

Expected Behavior

I expect no type errors in any of the examples provided.

Actual Behavior

The first example (with class A and Callable) is accepted. The second is not.

decorator_confusion.py:45: error: Too few arguments for "__call__" of "MyCallable"  [call-arg]

Your Environment

Tested on mypy 1.18.2 and 2.1.0. Python version 3.14.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions