Skip to content

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

Closed

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]?

Activity

  1. nightcityblade commented on Aug 12, 2026

    @nightcityblade
    Contributor

    Hi, I'd like to work on this. I'll submit a focused PR shortly.

  2. nightcityblade commented on Aug 12, 2026

    @nightcityblade
    Contributor

    I took a closer look and won't be able to complete this within the current contribution batch. Releasing it for someone else—sorry for the noise.

  3. srittau commented on Aug 12, 2026

    @srittau
    Collaborator

    I'm actually not sure why I changed this, this seems more like an accident and should be restored.

  4. Boulea7 commented on Aug 13, 2026

    @Boulea7
    Contributor

    I reproduced the loss of the Popen[str] and Popen[bytes] stream types on current main. I’ll restore the attributes to use the class type parameter and run the subprocess stub checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions