Skip to content

ParamSpec doesn't handle out-of-order kwargs for callable protocol #15984

Closed
@koogoro

Description

@koogoro

Bug Report

If you use a ParamSpec to accept a callable and its arguments, and supply keyword args in a different order than they appear in the arguments, mypy reports an error:
https://mypy-play.net/?mypy=master&python=3.11&gist=56911342c8a4d3326da4cc1265f1a156

This didn't happen on the last release, and in fact didn't happen as recently as 5d909f1. It does seem to happen only for callable protocols and not for functions.

Actual Behavior

main.py:12: error: Argument 1 to "g" has incompatible type "A"; expected "Callable[[int, str], None]"  [arg-type]
main.py:12: note: "A.__call__" has type "Callable[[Arg(str, 'x'), Arg(int, 'y')], None]"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-paramspecPEP 612, ParamSpec, Concatenate

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions