def __init__(self, stream: io.BufferedIOBase): if not isinstance(stream, io.BufferedIOBase): raise TypeError("need BufferedIOBase") self.stream = stream assert stream.isatty() is False and stream.seekable() is True