Skip to content

Give better error messages when there are covariance/invariance related errors #1115

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
JukkaL opened this issue Jan 11, 2016 · 1 comment
Closed

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jan 11, 2016

[The following is adapted from discussion at #1113. Go there for more context.]

We should give output like this for some invariance violations, as many programmers expect everything to be covariant and it may not be obvious why mypy is complaining:

$ mypy file.py
file.py:7: error: Argument 1 to "f" has incompatible type Dict[str, List[int]]; expected Dict[str, Sequence[int]]
file.py:8: note: The second type parameter of "Dict" is invariant; consider using "Mapping" instead, which is covariant

This would give more context even for somebody who doesn't understand covariance/invariance -- these terms are easy to google.

Even better, we could give a pointer to relevant documentation.

@quartox
Copy link
Contributor

quartox commented May 22, 2017

I will start looking at this.

ilevkivskyi pushed a commit that referenced this issue Aug 19, 2017
Fixes #1115 and #3352 by providing a link to docs and a suggestion.
This currently only takes care of 'List' and 'Dict', which are the most typical for this kind of errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants