Skip to content

perf: try to cache inner contexts of overloads #19408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Prev Previous commit
Next Next commit
Do not cache if errors are encountered in arguments themselves
  • Loading branch information
sterliakov committed Jul 18, 2025
commit 72fdf5d29c98fc5177131996ea57c09443f57818
19 changes: 12 additions & 7 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1968,13 +1968,18 @@ def infer_arg_types_in_empty_context(
return self._args_cache[key]
res: list[Type] = []

for arg in args:
arg_type = self.accept(arg)
if has_erased_component(arg_type):
res.append(NoneType())
else:
res.append(arg_type)
if can_cache:
with self.msg.filter_errors(filter_errors=True, save_filtered_errors=True) as w:
for arg in args:
arg_type = self.accept(arg)
if has_erased_component(arg_type):
res.append(NoneType())
else:
res.append(arg_type)

if w.has_new_errors():
self.msg.add_errors(w.filtered_errors())
elif can_cache:
# Do not cache if new diagnostics were emitted: they may impact parent overload
self._args_cache[key] = res
return res

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy