mypy complains about following piece of code:
from io import BytesIO
view = memoryview(b'ABCD')
bio = BytesIO(view)
target = BytesIO()
target.write(view)
The errors are:
test.py:4: error: Argument 1 to "BytesIO" has incompatible type "memoryview"; expected "bytes"
test.py:7: error: Argument 1 to "write" of "BytesIO" has incompatible type "memoryview"; expected "Union[bytes, bytearray]"
According to documentation BytesIO should be constructible from bytes-like object:
https://docs.python.org/3/library/io.html#io.BytesIO
which is among others memoryview: https://docs.python.org/3/glossary.html#term-bytes-like-object
Similarly argument to write should be bytes-like object:
https://docs.python.org/3/library/io.html#io.BufferedIOBase
mypy complains about following piece of code:
The errors are:
According to documentation BytesIO should be constructible from
bytes-like object:https://docs.python.org/3/library/io.html#io.BytesIO
which is among others
memoryview: https://docs.python.org/3/glossary.html#term-bytes-like-objectSimilarly argument to write should be
bytes-like object:https://docs.python.org/3/library/io.html#io.BufferedIOBase