Skip to content

Unbound type variables can leak out of type inference errors #7101

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
msullivan opened this issue Jun 28, 2019 · 1 comment · Fixed by #7113
Closed

Unbound type variables can leak out of type inference errors #7101

msullivan opened this issue Jun 28, 2019 · 1 comment · Fixed by #7113
Labels
bug mypy got something wrong priority-0-high semantic-analyzer Problems that happen during semantic analysis topic-type-variables

Comments

@msullivan
Copy link
Collaborator

This was introduced by #7079.

This file

from collections import defaultdict
def foo() -> None:
    x = defaultdict(list)  # type: ignore
    x['lol'].append(10)
    reveal_type(x)

produces these errors now.

asdf.py:4: error: Argument 1 to "append" of "list" has incompatible type "int"; expected "_T"
asdf.py:5: note: Revealed type is 'collections.defaultdict[Any, builtins.list[_T`1]]'

Previously it produced

asdf.py:5: note: Revealed type is 'Any'

Probably the correct revealed type would be collections.defaultdict[Any, Any].

This only shows up in a small handful of places at dropbox, though, and they can all be fixed by changing the # type: ignore to a # type: Any (or something better...)

@msullivan msullivan added the bug mypy got something wrong label Jun 28, 2019
@ilevkivskyi ilevkivskyi added semantic-analyzer Problems that happen during semantic analysis priority-1-normal labels Jun 28, 2019
@ilevkivskyi
Copy link
Member

Since the fix is trivial, I set the priority to high, so I will not forget about this on Monday.

JukkaL pushed a commit that referenced this issue Jul 1, 2019
Fixes #7101.

This fixes another manifestation of an old issue where 
type variables can leak where a generic function is passed 
as an argument to another generic function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-0-high semantic-analyzer Problems that happen during semantic analysis topic-type-variables
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants