Skip to content

Regression: No matching overload error in 0.780 upwards, while (correctly) not showing a warning in 0.770 and below #9458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rggjan opened this issue Sep 18, 2020 · 3 comments
Labels
bug mypy got something wrong

Comments

@rggjan
Copy link

rggjan commented Sep 18, 2020

This code:

from typing import List, Tuple, TypeVar

T = TypeVar("T")


def foo(x: T) -> None:
    a: List[Tuple[int, T]] = [(2, x)]

    for t in zip(*a):
        reveal_type(t)
        list(t)

produces the warning:

main.py:10: note: Revealed type is 'builtins.object'
main.py:11: error: No overload variant of "list" matches argument type "object"
main.py:11: note: Possible overload variant:
main.py:11: note:     def [_T] __init__(self, iterable: Iterable[_T]) -> List[_T]
main.py:11: note:     <1 more non-matching overload not shown>

when running mypy test.py on 0.780.

Running the same through mypy 0.770 works fine and doesn't produce a warning.

(Also, running the example works fine of course)

@rggjan rggjan added the bug mypy got something wrong label Sep 18, 2020
@gvanrossum
Copy link
Member

Hm, in 0.770 the revealed type is tuple[Any], which is arguably better indeed, and seems to match what happens at runtime. zip's type is a complex overload -- maybe something changed there since 0.770?

@JelleZijlstra
Copy link
Member

I think this is python/typeshed#4226; we got too clever with zip() and had to revert. Does it work for you on current master?

@gvanrossum
Copy link
Member

Oh, yeah, this is fixed on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

3 participants