Skip to content

Commit 277ee69

Browse files
committed
Experiment: literally just ignore the context altogether?
1 parent 917d781 commit 277ee69

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mypy/checkexpr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2902,6 +2902,9 @@ def infer_overload_return_type(
29022902
assert self.msg is self.chk.msg
29032903
with self.msg.filter_errors() as w:
29042904
with self.chk.local_type_map as m:
2905+
# Overload selection should not depend on the context.
2906+
# During this step pretend that we do not have any external information.
2907+
self.type_context.append(None)
29052908
ret_type, infer_type = self.check_call(
29062909
callee=typ,
29072910
args=args,
@@ -2911,6 +2914,7 @@ def infer_overload_return_type(
29112914
callable_name=callable_name,
29122915
object_type=object_type,
29132916
)
2917+
self.type_context.pop()
29142918
is_match = not w.has_new_errors()
29152919
if is_match:
29162920
# Return early if possible; otherwise record info, so we can

test-data/unit/check-overloading.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6865,5 +6865,5 @@ def gather(*fns: object) -> int: ...
68656865

68666866
def crash() -> None:
68676867
foo: str
6868-
(foo,) = gather(0)
6868+
(foo,) = gather(0) # E: Incompatible types in assignment (expression has type "int", variable has type "str")
68696869
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)