Skip to content

Commit df93509

Browse files
committed
Explicitly check for ast.Name
1 parent 805530f commit df93509

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pre_commit_hooks/check_builtin_literals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _check_dict_call(self, node):
3030
return self.allow_dict_kwargs and (getattr(node, 'kwargs', None) or getattr(node, 'keywords', None))
3131

3232
def visit_Call(self, node):
33-
if isinstance(node.func, ast.Attribute):
33+
if not isinstance(node.func, ast.Name):
3434
# Ignore functions that are object attributes (`foo.bar()`).
3535
# Assume that if the user calls `builtins.list()`, they know what
3636
# they're doing.

tests/check_builtin_literals_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def visitor():
1616
@pytest.mark.parametrize(
1717
('expression', 'calls'),
1818
[
19+
# see #285
20+
('x[0]()', []),
1921
# complex
2022
("0j", []),
2123
("complex()", [BuiltinTypeCall('complex', 1, 0)]),

0 commit comments

Comments
 (0)