Skip to content

Commit

Permalink
Merge pull request #144 from bcaller/bc-py35-dict
Browse files Browse the repository at this point in the history
Vars visitor handles python 3.5 dict syntax
  • Loading branch information
KevinHock committed Jul 13, 2018
2 parents a2c4615 + 6b3f155 commit c7a932f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyt/helper_visitors/vars_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def visit_IfExp(self, node):

def visit_Dict(self, node):
for k in node.keys:
self.visit(k)
if k is not None:
self.visit(k)
for v in node.values:
self.visit(v)

Expand Down
4 changes: 4 additions & 0 deletions tests/helper_visitors/vars_visitor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,7 @@ async def bar():
await foo()
""".lstrip())
self.assertEqual(vars.result, [])

def test_visit_dict(self):
vars = self.perform_vars_on_expression('a = {k1: v1, k2: v2, **d1, **d2}')
self.assertEqual(vars.result, ['a', 'k1', 'k2', 'v1', 'v2', 'd1', 'd2'])

0 comments on commit c7a932f

Please sign in to comment.