Skip to content

Commit

Permalink
Support lambda invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Oct 18, 2024
1 parent 90f7ed5 commit 07da017
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rewrite/rewrite/python/_parser_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
Expand Down
5 changes: 5 additions & 0 deletions rewrite/tests/python/all/method_invocation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"))
Expand Down

0 comments on commit 07da017

Please sign in to comment.