Explicitly check for ast.Name

This commit is contained in:
Anthony Sottile 2018-05-17 17:14:25 -07:00
parent 805530fe29
commit df93509aed
2 changed files with 3 additions and 1 deletions

View file

@ -30,7 +30,7 @@ class BuiltinTypeVisitor(ast.NodeVisitor):
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.

View file

@ -16,6 +16,8 @@ def visitor():
@pytest.mark.parametrize(
('expression', 'calls'),
[
# see #285
('x[0]()', []),
# complex
("0j", []),
("complex()", [BuiltinTypeCall('complex', 1, 0)]),