check-builtin-literals: Ignore function attribute calls

This commit is contained in:
Ben Webber 2017-11-30 18:27:16 +00:00
parent 3ab8c71f56
commit 775867626d
4 changed files with 25 additions and 1 deletions

View file

@ -30,6 +30,11 @@ 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):
# Ignore functions that are object attributes (`foo.bar()`).
# Assume that if the user calls `builtins.list()`, they know what
# they're doing.
return
if node.func.id not in set(BUILTIN_TYPES).difference(self.ignore):
return
if node.func.id == 'dict' and self._check_dict_call(node):