Skip to content

Popen.std* attributes are now IO[Any] #15827

@DetachHead

Description

@DetachHead

in #15654, these attributes were made less typesafe by changing their type from IO[AnyStr] to IO[Any]:

from subprocess import PIPE, Popen

with Popen(["echo", "hi"], stdout=PIPE, text=True) as process:
    if process.stdout:
        for line in process.stdout:
            line.asdfasdf # no type error, crashes at runtime

there didn't seem to be any explanation for this change in that PR which is why i'm opening a new issue. is there a reason the types can't be IO[AnyStr]?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions