Skip to content

Incorrect and incomplete type annotations for container.run() #589

@jonathanunderwood

Description

@jonathanunderwood

The type annotation for container.run() here is Union[Container, Union[Generator[str, None, None], Iterator[str]]].

The docstring for the return type states:

        Returns:
            - When detach is True, return a Container
            - If stdout is True, include stdout from container in output
            - If stderr is True, include stderr from container in output
            - When stream is True, output from container is returned as a generator
            - Otherwise, an iterator is returned after container has finished

So, when stream is True, according to the return type, one would expect Generator[str, None, None] as the return type. In fact, what is returned is [Generator[bytes, None, None]. I am not sure if this is a bug in the type annotation, or incorrect implementation, and decoding to a string is actually expected.

In addition, those conditional return types really should be encoded as a set of overlad annotations for that method - the current type hint is pretty useless as is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions