Skip to content

Commit

Permalink
Ignore lambda expressions in analyzer
Browse files Browse the repository at this point in the history
Fixes aws#74.
  • Loading branch information
jamesls committed Aug 1, 2016
1 parent 43f4d5f commit 4fc8031
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ Next Release
(`#65 <https://github.com/awslabs/chalice/issues/65>`__)
* Validate duplicate route entries
(`#79 <https://github.com/awslabs/chalice/issues/79>`__)
* Ignore lambda expressions in policy analyzer
(`#74 <https://github.com/awslabs/chalice/issues/74>`__)
8 changes: 8 additions & 0 deletions chalice/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ def visit_Call(self, node):
self._symbol_table.has_ast_node_for_symbol(node.func.id):
self._infer_function_call(node)

def visit_Lambda(self, node):
# Lambda is going to be a bit tricky because
# there's a new child namespace (via .get_children()),
# but it's not something that will show up in the
# current symbol table via .lookup().
# For now, we're going to ignore lambda expressions.
pass

def _infer_function_call(self, node):
# Here we're calling a function we haven't analyzed
# yet. We're first going to analyze the function.
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ def foo():
""") == {'s3': set(['list_buckets']), 'dynamodb': set(['list_tables'])}


def test_can_handle_lambda_keyword():
assert aws_calls("""\
def foo(a):
return sorted(bar.values(),
key=lambda x: x.baz[a - 1],
reverse=True)
bar = {}
foo(12)
""") == {}

#def test_tuple_assignment():
# assert aws_calls("""\
# import boto3
Expand Down

0 comments on commit 4fc8031

Please sign in to comment.