Use TypedDict fallback as its suggestion representation (#7606)
diff --git a/mypy/suggestions.py b/mypy/suggestions.py index 19879de..427655e 100644 --- a/mypy/suggestions.py +++ b/mypy/suggestions.py
@@ -33,6 +33,7 @@ TypeVarType, FunctionLike, TypeStrVisitor, TypeTranslator, is_optional, remove_optional, ProperType, get_proper_type, + TypedDictType ) from mypy.build import State, Graph from mypy.nodes import ( @@ -711,6 +712,9 @@ s = self.list_str(t.items) return 'Tuple[{}]'.format(s) + def visit_typeddict_type(self, t: TypedDictType) -> str: + return t.fallback.accept(self) + def visit_union_type(self, t: UnionType) -> str: if len(t.items) == 2 and is_optional(t): return "Optional[{}]".format(remove_optional(t).accept(self))
diff --git a/test-data/unit/fine-grained-suggest.test b/test-data/unit/fine-grained-suggest.test index b069211..490d976 100644 --- a/test-data/unit/fine-grained-suggest.test +++ b/test-data/unit/fine-grained-suggest.test
@@ -139,6 +139,20 @@ () -> foo.N == +[case testSuggestInferTypedDict] +# suggest: foo.foo +[file foo.py] +from typing_extensions import TypedDict +TD = TypedDict('TD', {'x': int}) +def foo(): + return bar() + +def bar() -> TD: ... +[builtins fixtures/dict.pyi] +[out] +() -> foo.TD +== + [case testSuggestReexportNaming] # suggest: foo.foo [file foo.py]