mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 19:26:52 +00:00
check-builtin-literals: Ignore function attribute calls
This commit is contained in:
parent
3ab8c71f56
commit
775867626d
4 changed files with 25 additions and 1 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue