Skip to content

Regression in determining return type of zip() on tuples #4226

Closed
@mthuurne

Description

@mthuurne

On the following code:

z = zip((1, 2, 3), ('a', 'b', 'c'))
reveal_type(z)

mypy 0.770 will output:

Revealed type is 'typing.Iterator[Tuple[builtins.int*, builtins.str*]]

while mypy 0.780 will output:

Revealed type is 'Tuple[builtins.tuple[builtins.object*], builtins.tuple[builtins.object*], builtins.tuple[builtins.object*]]'

The output from 0.770 is both more correct (since the zip object is not a tuple) and more useful (since the types of the elements are known).

The fix for python/mypy#8454 adds additional overloaded definitions for zip(*...) in typeshed, which in itself is useful. However, for some reason mypy seems to prefer the new 'star' definitions to the older and more correct 'non-star' definitions, which causes this regression.

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