So, i using mypy to learn how to code in python using type check from the beginning. I'm using this code to train:
def stars(*args: int, **kwargs: float) -> None:
for arg in args:
print(arg)
for key, value in kwargs:
print(key, value)
stars(1.3,1.3)
I'm getting this typeerror:
learning_mypy.py:6: error: Unpacking a string is disallowed
learning_mypy.py:7: error: Cannot determine type of 'key'
learning_mypy.py:7: error: Cannot determine type of 'value'
learning_mypy.py:9: error: Argument 1 to "stars" has incompatible type "float"; expected "int"
learning_mypy.py:9: error: Argument 2 to "stars" has incompatible type "float"; expected "int"
Found 5 errors in 1 file (checked 1 source file)
So my questions are:
- Why error
mypy.py:6
is happening? - How do i define the type the value for
key
andvalue
? - Why error
mypy.py:9
is hapening?