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
I'm getting a strange mypy error when calling aiohttp.web.Request.clone with a dict of parameters expanded with **. Is there some trick or missing feature to calling functions with ** expansion of parameters that I'm missing?
~ ❯ cat foo.py
from aiohttp import web
def foo(request: web.Request) -> web.Request:
overrides = {"remote": "1.1.1.1", "scheme": "https"}
return request.clone(**overrides)
~ ❯ mypy foo.py
foo.py:5: error: Argument 1 to "clone" of "Request" has incompatible type "**Dict[str, str]"; expected "Union[Mapping[Union[str, istr], str], CIMultiDict[str], CIMultiDictProxy[str]]"
Found 1 error in 1 file (checked 1 source file)
It looks like the messy type is coming from LooseHeaders, and indeed str is not a valid type for LooseHeaders. Is that what mypy is complaining about? If so, is there a way to write this code that mypy will be happy with? (In my actual code, the overrides are dynamically determined.)
This is with Python 3.8.3rc1 and mypy 0.770, and aiohttp 3.6.2.
The text was updated successfully, but these errors were encountered:
I'm getting a strange mypy error when calling
aiohttp.web.Request.clone
with a dict of parameters expanded with**
. Is there some trick or missing feature to calling functions with**
expansion of parameters that I'm missing?The relevant prototype is:
It looks like the messy type is coming from
LooseHeaders
, and indeedstr
is not a valid type forLooseHeaders
. Is that what mypy is complaining about? If so, is there a way to write this code that mypy will be happy with? (In my actual code, the overrides are dynamically determined.)This is with Python 3.8.3rc1 and mypy 0.770, and aiohttp 3.6.2.
The text was updated successfully, but these errors were encountered: