Skip to content

Mypy incorrectly warns when passing literals as kwarg keywords #10023

Description

@nipunn1313

Bug Report

from typing import Any, Dict, Literal
kw: Dict[Literal["a", "b"], Any]
def func(a, b):
    pass
func(**kw)

Leads to

main.py:8: error: Keywords must be strings

https://mypy-play.net/?mypy=latest&python=3.9&gist=582cf5e8c0a6e6a5881d391da64e1455

Expected Behavior
Expect this to be allowable - as these literals count as strings

Activity

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 wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions