Skip to content

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

Closed
@msullivan

Description

@msullivan

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...)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions