Skip to content

Commit

Permalink
Use .get method instead of in operator to get value from inferenc…
Browse files Browse the repository at this point in the history
…e cache safely
  • Loading branch information
JCZuurmond committed Oct 10, 2024
1 parent 0954cd4 commit 7266b50
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions astroid/nodes/node_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ def infer(
pass

key = (self, context.lookupname, context.callcontext, context.boundnode)
if key in context.inferred:
yield from context.inferred[key]
cached_result = context.inferred.get(key)
if cached_result is not None:
yield from cached_result
return

results = []
Expand Down

0 comments on commit 7266b50

Please sign in to comment.