-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Description
from typing import Dict
def greet(**xyz: Dict[str,str]) -> None:
print(xyz)
greet(a="pakistan", b='China')
here the bug is
Argument of type "Literal['pakistan']" cannot be assigned to parameter "a" of type "Dict[str, str]" in function "greet"
"Literal['pakistan']" is incompatible with "Dict[str, str]"
correct code is
def greet(**xyz: str) -> None:
print(xyz)
greet(a="pakistan", b='China')
here str indicates that each keyword argument should be a string. When calling greet, you can directly pass key-value pairs where both the keys and values are strings. The function will then receive them as a dictionary with string keys and string values. This should resolve the static type error.
Metadata
Metadata
Assignees
Labels
No labels