Here's an example:
import requests
params = {
'something': 'cool',
'a number': 1,
}
res = requests.get('http://www.google.com', params)
print(res.status_code, res.text)
And here's the output:
test_requests.py:8: error: Argument 2 has incompatible type Dict[str, object]; expected union type (7 items)
Thanks for reporting this!
This is related to how mypy infers types. It (on purpose) tries to be naive. You could use an explicit annotation in such cases to specify a more precise type:
params: Dict[str, Union[int, str]] = {
'something': 'cool',
'a number': 1,
}
I just tried it on master, and it works with the above annotation.
Most helpful comment
Thanks for reporting this!
This is related to how mypy infers types. It (on purpose) tries to be naive. You could use an explicit annotation in such cases to specify a more precise type:
I just tried it on master, and it works with the above annotation.