Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14155

AttributeError: '_io.StringIO' object has no attribute 'buffer'?

$
0
0

I have this function that simply writes a string into a stream buffer:

import sysfrom typing import IOdef write(s: str, stream: IO[bytes] = sys.stdout.buffer):    stream.write(s.encode())    stream.flush()

I'm using both flake8 and mypy which don't complaint while pdoc throws an attribute error:

[...]    def write(s: str, stream: IO[bytes] = sys.stdout.buffer):AttributeError: '_io.StringIO' object has no attribute 'buffer'

Is there a way to fix this?


Viewing all articles
Browse latest Browse all 14155

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>