Skip to content

Commit

Permalink
Merge pull request #286 from pre-commit/fix_builtin_literals_check
Browse files Browse the repository at this point in the history
Explicitly check for `ast.Name`
  • Loading branch information
asottile authored May 18, 2018
2 parents 805530f + df93509 commit a66a330
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pre_commit_hooks/check_builtin_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _check_dict_call(self, node):
return self.allow_dict_kwargs and (getattr(node, 'kwargs', None) or getattr(node, 'keywords', None))

def visit_Call(self, node):
if isinstance(node.func, ast.Attribute):
if not isinstance(node.func, ast.Name):
# Ignore functions that are object attributes (`foo.bar()`).
# Assume that if the user calls `builtins.list()`, they know what
# they're doing.
Expand Down
2 changes: 2 additions & 0 deletions tests/check_builtin_literals_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def visitor():
@pytest.mark.parametrize(
('expression', 'calls'),
[
# see #285
('x[0]()', []),
# complex
("0j", []),
("complex()", [BuiltinTypeCall('complex', 1, 0)]),
Expand Down

0 comments on commit a66a330

Please sign in to comment.