Skip to content

contextlib.redirect_stdout is asking for more than it needs #14903

@beauxq

Description

@beauxq

contextlib.redirect_stdout and contextlib.redirect_stderr according to typeshed right now, require a parameter of typing.IO[str]

If I make a class that inherits IO[str], it requires implementing other methods that aren't really needed.

In practice, write and flush alone have worked for me in multiple projects for a long time.

What do we think of using a Protocol with just write and flush, instead of IO[str]?

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: ioI/O related issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions