def _check_tuple_arguments_types( self, node: ast.Call, ) -> None: is_checkable = (isinstance(node.func, ast.Name) and node.func.id in constants.TUPLE_ARGUMENTS_METHODS) if not is_checkable: return all_args = call_args.get_all_args(node) for arg in all_args: if isinstance(arg, self._no_tuples_collections): self.add_violation(NotATupleArgumentViolation(node)) break
def is_primitive(node: ast.AST) -> bool: """ Detects if node is a form of a primitive value. We use this predicate to allow values like ``[]`` or ``call()`` to be overused. Because you cannot simplify them. We do not check for strings, numbers, etc because they are globally ignored. """ if isinstance(node, (ast.Tuple, ast.List)): return not node.elts # we do allow `[]` and `()` elif isinstance(node, ast.Set): return ( # we do allow `{*set_items}` len(node.elts) == 1 and isinstance(node.elts[0], ast.Starred)) elif isinstance(node, ast.Dict): # we do allow `{}` and `{**values}` return not list(filter(None, node.keys)) elif isinstance(node, ast.Call): return not call_args.get_all_args(node) # we do allow `call()` return False
def visit_Call(self, node: ast.Call) -> None: """Checks call arguments indentation.""" all_args = call_args.get_all_args(node) self._check_indentation(node, all_args) self.generic_visit(node)