Skip to content

Confusing error message when using incompatible type on '*args' style tuple argument #1765

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
onnokort opened this issue Jun 29, 2016 · 4 comments

Comments

@onnokort
Copy link

Hi,

for the attached file

msg.py.txt

I get the following error message:

msg.py.txt: note: In member "fn" of class "SomeClass":
msg.py.txt:10: error: Argument 1 to "tuple" has incompatible type Set[int]; expected Iterable[...]

I was expecting something like "has incompatible type Set[int]; expected Iterable[Callable]". The "..." is confusing, as it seems to hint at Set[..] not following the Iterable[...] protocol.

@gvanrossum
Copy link
Member

Please show examples inline. For posterity: here it is:

from typing import Callable

class SomeClass(object):
    def __init__(self): #type: (SomeClass) -> None
        self.x=set() # type: Set[Callable]
        self.mx=set() #type: Set[int]

    def fn(self, *a): #type: (SomeClass, *Callable) -> None
        if not len(a):
            a=(tuple(self.x) + tuple(self.mx))        

@gvanrossum
Copy link
Member

The reason is probably that mypy shortens the text of types occurring in error messages. I think there's already another issue asking to show the full type (or at least to make the limit much larger).

@gvanrossum
Copy link
Member

See the discussion in #287.

@ilevkivskyi
Copy link
Member

Mypy now shows the full type Iterable[Callable[..., Any]], so this is fixed.

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

No branches or pull requests

3 participants