Skip to content

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

Closed

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]"

Activity

  1. ilevkivskyi commented on Aug 29, 2023

    @ilevkivskyi
    Member

    Yeah, this is caused by my PR. I will take a look later today (It is sad we don't have something like get_proper_type() and plugin for CallableType, maybe we should write one, but I guess it may be a pain to use, since we don't have checkmember infra available in many places, so it comes back again to #7724)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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