Skip to content

Unexpected Any for complex import structure #4110

Closed
@matzipan

Description

@matzipan

Hello guys, I have the following snippet:

def blabla_call(command: List[str], modules: Optional[List[str]] = None) -> Tuple[int, str]:
    if modules is None:
        modules = []

    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

    output_buffer = io.StringIO()

    for line in process.stdout:
        decoded_line = line.decode("utf-8")
        sys.stdout.write(decoded_line)
        output_buffer.write(decoded_line)

    if process.returncode:
        raise RuntimeError("Shell command failure")

    return process.returncode, output_buffer.getvalue()

def make_step(options: Iterable[str]) -> Tuple[int, str]:
     return blabla_call(["make"])

On the very last line of the function make_step the following warning is reported only when running with --strict enabled: warning: Returning Any from function declared to return "Tuple[int, str]".

This sounds like a type propagation bug of sorts in mypy since there is no error reported in the type defintion of blabla_call, but only further on does mypy get confused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions