From 07da017fd32b3f773f9256917e8137e054117bf1 Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Fri, 18 Oct 2024 16:07:12 +0200 Subject: [PATCH] Support lambda invocations --- rewrite/rewrite/python/_parser_visitor.py | 2 +- rewrite/tests/python/all/method_invocation_test.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rewrite/rewrite/python/_parser_visitor.py b/rewrite/rewrite/python/_parser_visitor.py index 9467e905..af169829 100644 --- a/rewrite/rewrite/python/_parser_visitor.py +++ b/rewrite/rewrite/python/_parser_visitor.py @@ -1156,7 +1156,7 @@ def visit_Call(self, node): self.__map_type(node.func.value), None ) - elif isinstance(node.func, (ast.Call, ast.Subscript)): + elif isinstance(node.func, (ast.Call, ast.Lambda, ast.Subscript)): select = self.__pad_right(cast(Expression, self.__convert(node.func)), self.__whitespace()) # printer handles empty name by not printing `.` before it name = self.__convert_name('') diff --git a/rewrite/tests/python/all/method_invocation_test.py b/rewrite/tests/python/all/method_invocation_test.py index 687d59d8..1af3cc5b 100644 --- a/rewrite/tests/python/all/method_invocation_test.py +++ b/rewrite/tests/python/all/method_invocation_test.py @@ -18,6 +18,11 @@ def test_invoke_function_receiver(): rewrite_run(python("assert a(0)(1)")) +def test_invoke_lambda_receiver(): + # language=python + rewrite_run(python("assert (lambda x: x)(1)")) + + def test_invoke_array_access_receiver(): # language=python rewrite_run(python("assert a[0](1)"))