You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
OsamaAiDev
changed the title
I found Type Bug In Class10 **kwargs
I found Type Bug In Class10 **kwargs Function Example
Mar 31, 2024
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.
The text was updated successfully, but these errors were encountered: