Skip to content

Commit 89439a0

Browse files
committed
handle-lambda
1 parent 8bc79d6 commit 89439a0

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

IPython/core/guarded_eval.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,13 @@ def dummy_function(*args, **kwargs):
779779
dummy_function.__is_async__ = is_async
780780
context.transient_locals[node.name] = dummy_function
781781
return None
782+
if isinstance(node, ast.Lambda):
783+
784+
def dummy_function(*args, **kwargs):
785+
pass
786+
787+
dummy_function.__inferred_return__ = eval_node(node.body, context)
788+
return dummy_function
782789
if isinstance(node, ast.ClassDef):
783790
# TODO support class decorators?
784791
class_locals = {}
@@ -961,7 +968,7 @@ def dummy_function(*args, **kwargs):
961968
return overridden_return_type
962969
return _create_duck_for_heap_type(func)
963970
else:
964-
inferred_return = getattr(func, "__inferred_return__", None)
971+
inferred_return = getattr(func, "__inferred_return__", NOT_EVALUATED)
965972
return_type = _eval_return_type(func, node, context)
966973
if getattr(func, "__is_async__", False):
967974
awaited_type = (
@@ -970,7 +977,7 @@ def dummy_function(*args, **kwargs):
970977
coroutine_duck = ImpersonatingDuck()
971978
coroutine_duck.__awaited_type__ = awaited_type
972979
return coroutine_duck
973-
if inferred_return:
980+
if inferred_return is not NOT_EVALUATED:
974981
return inferred_return
975982
if return_type is not NOT_EVALUATED:
976983
return return_type

0 commit comments

Comments
 (0)