def check_arguments_count(self, node: AnyFunctionDefAndLambda) -> None: """Checks the number of the arguments in a function.""" has_extra_arg = 0 if functions.is_method(getattr(node, 'function_type', None)): has_extra_arg = 1 arguments = functions.get_all_arguments(node) self.arguments[node] = len(arguments) - has_extra_arg
def _check_bound_methods(self, node: types.AnyFunctionDef) -> None: node_context = get_context(node) if not isinstance(node_context, ast.ClassDef): return if len(get_all_arguments(node)) == 0: self.add_violation( MethodWithoutArgumentsViolation(node, text=node.name), ) if node.name in constants.MAGIC_METHODS_BLACKLIST: self.add_violation(BadMagicMethodViolation(node, text=node.name))
def check_function_signature(self, node: AnyFunctionDefAndLambda) -> None: arguments = functions.get_all_arguments(node) is_lambda = isinstance(node, ast.Lambda) for arg in arguments: should_check_argument = functions.is_first_argument( node, arg.arg, ) and not is_lambda self.check_name( arg, arg.arg, is_first_argument=should_check_argument, )
def visit_any_function(self, node: AnyFunctionDef) -> None: """Checks function parameters indentation.""" self._check_indentation(node, get_all_arguments(node)) self.generic_visit(node)
def check_arguments_count(self, node: AnyFunctionDefAndLambda) -> None: """Checks the number of the arguments in a function.""" self.arguments[node] = len(functions.get_all_arguments(node))