read of SpooledTemporaryFile returns bytes, mypy assumes str #3360
Labels
stubs: false negative
Type checkers do not report an error, but should
stubs: false positive
Type checkers report false errors
I think this is correct here and not in the
mypy
repo (if I'm wrong, I am happy to open a ticket there):following code
works fine with python3.7 . Using mypy (also with python 3.7) I get the following error:
Mypy incorrectly assumes that the result of the read is a
str
but using the interactive interpreter you'll see that theread
method actually returns abyte
object. The type annotations (https://github.com/python/typeshed/blob/master/stdlib/3/tempfile.pyi) sayAnyStr
as return type which is too narrow in this case.The text was updated successfully, but these errors were encountered: