Skip to content

Weird, but legal ** syntax not accepted #5580

Closed

Description

@warsaw

I saw this in real code, although I don't really understand the reason why this is done. Still, even though it's a bit weird, it's legal and I think mypy should allow it:

class Foo:
    def __init__(self, a=1, b=2):
        self.a = a
        self.b = b


Foo(**{})
$ mypy foo.py
foo.py:7: error: Keywords must be strings

Activity

  1. gvanrossum commented on Sep 6, 2018

    @gvanrossum
    Member

    Agreed -- the dict could be type-checked here with a context of Mapping[str, Any] and that would make the empty dict have the type Dict[str, Any] rather than Dict[<nothing>, <nothing>].

    Low priority though.

  2. added a commit that references this issue on Aug 26, 2021
    ea7fed1
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions