Skip to content

Commit 22a5a4f

Browse files
authored
Revert "[suggest] Fix inference of returned collection (#7810)" (#7827)
This reverts commit 766d58f. Fixes #7826.
1 parent 03da3fc commit 22a5a4f

File tree

4 files changed

+3
-27
lines changed

4 files changed

+3
-27
lines changed

mypy/checkexpr.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3593,11 +3593,6 @@ def accept(self,
35933593
"""
35943594
if node in self.type_overrides:
35953595
return self.type_overrides[node]
3596-
# Don't use an Any type context, since that will cause more
3597-
# anys than we want for things that consume the inferred
3598-
# types.
3599-
if isinstance(get_proper_type(type_context), AnyType):
3600-
type_context = None
36013596
self.type_context.append(type_context)
36023597
try:
36033598
if allow_none_return and isinstance(node, CallExpr):

mypy/suggestions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
from mypy.state import strict_optional_set
3131
from mypy.types import (
3232
Type, AnyType, TypeOfAny, CallableType, UnionType, NoneType, Instance, TupleType,
33-
TypeVarType, FunctionLike, TypedDictType, UninhabitedType,
33+
TypeVarType, FunctionLike,
3434
TypeStrVisitor, TypeTranslator,
3535
is_optional, remove_optional, ProperType, get_proper_type,
36+
TypedDictType
3637
)
3738
from mypy.build import State, Graph
3839
from mypy.nodes import (
@@ -721,9 +722,6 @@ def visit_tuple_type(self, t: TupleType) -> str:
721722
s = self.list_str(t.items)
722723
return 'Tuple[{}]'.format(s)
723724

724-
def visit_uninhabited_type(self, t: UninhabitedType) -> str:
725-
return "Any"
726-
727725
def visit_typeddict_type(self, t: TypedDictType) -> str:
728726
return t.fallback.accept(self)
729727

test-data/unit/fine-grained-suggest.test

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -803,23 +803,6 @@ z = foo(f(), g())
803803
(foo.List[Any], UNKNOWN) -> Tuple[foo.List[Any], Any]
804804
==
805805

806-
[case testSuggestDict]
807-
# suggest: foo.foo
808-
# suggest: foo.bar
809-
[file foo.py]
810-
def foo():
811-
# return dict(x=5)
812-
return {'x': 5}
813-
814-
def bar():
815-
return {}
816-
817-
[builtins fixtures/dict.pyi]
818-
[out]
819-
() -> typing.Dict[str, int]
820-
() -> typing.Dict[Any, Any]
821-
==
822-
823806
[case testSuggestWithErrors]
824807
# suggest: foo.foo
825808
[file foo.py]

test-data/unit/typexport-basic.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ from typing import Any
672672
a = [] # type: Any
673673
[builtins fixtures/list.pyi]
674674
[out]
675-
ListExpr(2) : builtins.list[<nothing>]
675+
ListExpr(2) : builtins.list[Any]
676676

677677
[case testHigherOrderFunction]
678678
from typing import TypeVar, Callable, List

0 commit comments

Comments
 (0)