Skip to content

Commit 72fdf5d

Browse files
committed
Do not cache if errors are encountered in arguments themselves
1 parent 1cbfab9 commit 72fdf5d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

mypy/checkexpr.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,13 +1968,18 @@ def infer_arg_types_in_empty_context(
19681968
return self._args_cache[key]
19691969
res: list[Type] = []
19701970

1971-
for arg in args:
1972-
arg_type = self.accept(arg)
1973-
if has_erased_component(arg_type):
1974-
res.append(NoneType())
1975-
else:
1976-
res.append(arg_type)
1977-
if can_cache:
1971+
with self.msg.filter_errors(filter_errors=True, save_filtered_errors=True) as w:
1972+
for arg in args:
1973+
arg_type = self.accept(arg)
1974+
if has_erased_component(arg_type):
1975+
res.append(NoneType())
1976+
else:
1977+
res.append(arg_type)
1978+
1979+
if w.has_new_errors():
1980+
self.msg.add_errors(w.filtered_errors())
1981+
elif can_cache:
1982+
# Do not cache if new diagnostics were emitted: they may impact parent overload
19781983
self._args_cache[key] = res
19791984
return res
19801985

0 commit comments

Comments
 (0)