I have this function that simply writes a string into a stream buffer:
import sys
from typing import IO
def 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?
Not really a solution but since stdout is a
TextIOI've rewritten the function as: