Skip to content

Commit

Permalink
Revert "[suggest] Fix inference of returned collection (#7810)" (#7827)
Browse files Browse the repository at this point in the history
This reverts commit 766d58f.

Fixes #7826.
  • Loading branch information
JukkaL authored Oct 30, 2019
1 parent 03da3fc commit 22a5a4f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 27 deletions.
5 changes: 0 additions & 5 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3593,11 +3593,6 @@ def accept(self,
"""
if node in self.type_overrides:
return self.type_overrides[node]
# Don't use an Any type context, since that will cause more
# anys than we want for things that consume the inferred
# types.
if isinstance(get_proper_type(type_context), AnyType):
type_context = None
self.type_context.append(type_context)
try:
if allow_none_return and isinstance(node, CallExpr):
Expand Down
6 changes: 2 additions & 4 deletions mypy/suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
from mypy.state import strict_optional_set
from mypy.types import (
Type, AnyType, TypeOfAny, CallableType, UnionType, NoneType, Instance, TupleType,
TypeVarType, FunctionLike, TypedDictType, UninhabitedType,
TypeVarType, FunctionLike,
TypeStrVisitor, TypeTranslator,
is_optional, remove_optional, ProperType, get_proper_type,
TypedDictType
)
from mypy.build import State, Graph
from mypy.nodes import (
Expand Down Expand Up @@ -721,9 +722,6 @@ def visit_tuple_type(self, t: TupleType) -> str:
s = self.list_str(t.items)
return 'Tuple[{}]'.format(s)

def visit_uninhabited_type(self, t: UninhabitedType) -> str:
return "Any"

def visit_typeddict_type(self, t: TypedDictType) -> str:
return t.fallback.accept(self)

Expand Down
17 changes: 0 additions & 17 deletions test-data/unit/fine-grained-suggest.test
Original file line number Diff line number Diff line change
Expand Up @@ -803,23 +803,6 @@ z = foo(f(), g())
(foo.List[Any], UNKNOWN) -> Tuple[foo.List[Any], Any]
==

[case testSuggestDict]
# suggest: foo.foo
# suggest: foo.bar
[file foo.py]
def foo():
# return dict(x=5)
return {'x': 5}

def bar():
return {}

[builtins fixtures/dict.pyi]
[out]
() -> typing.Dict[str, int]
() -> typing.Dict[Any, Any]
==

[case testSuggestWithErrors]
# suggest: foo.foo
[file foo.py]
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/typexport-basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ from typing import Any
a = [] # type: Any
[builtins fixtures/list.pyi]
[out]
ListExpr(2) : builtins.list[<nothing>]
ListExpr(2) : builtins.list[Any]

[case testHigherOrderFunction]
from typing import TypeVar, Callable, List
Expand Down

0 comments on commit 22a5a4f

Please sign in to comment.