INNER CODE UNIT · Python

_stream_with_preserved_newlines

PyCQA/isort · isort/main.py:57

def _stream_with_preserved_newlines(
    stream: TextIO, *, mode: Literal["r", "w"]
) -> AbstractContextManager[TextIO]:
    if stream is not sys.stdin and stream is not sys.stdout:
        return nullcontext(stream)
    try:
        stream_fileno = stream.fileno()
    except OSError:
        return nullcontext(stream)

    return open(
        stream_fileno,
        mode,
        encoding=stream.encoding,
        errors=stream.errors,
        newline="",
        closefd=False,
    )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…