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
Since response is a "file-like object" (i.e. has a .read() method). And json.load(fp, ...) operates on those according to the documentation ("Deserialize fp (a .read()-supporting file-like object containing a JSON document) to a Python object") I expect this to work.
$ mypy http.py
http.py:8: error: Argument 1 to "load" has incompatible type"HTTPResponse"; expected IO[str]
The text was updated successfully, but these errors were encountered:
Mypy doesn't currently support structural typing, although there is an active proposal to add it (see python/typing#11 and python/peps#224). Once that's implemented we could add a Protocol that defines the read method, but until then I'm not sure there's any better workaround than using cast() or # type: ignore.
Python v3.6
Mypy v0.501
Since
response
is a "file-like object" (i.e. has a.read()
method). Andjson.load(fp, ...)
operates on those according to the documentation ("Deserialize fp (a .read()-supporting file-like object containing a JSON document) to a Python object") I expect this to work.The text was updated successfully, but these errors were encountered: