def get_param_names(self, special_args=True): result = [pycompat.get_ast_arg_arg(node) for node in self.arguments.args if isinstance(node, pycompat.ast_arg_type)] if self.arguments.vararg: result.append('*' + pycompat.get_ast_arg_arg(self.arguments.vararg)) if self.arguments.kwarg: result.append('**' + pycompat.get_ast_arg_arg(self.arguments.kwarg)) return result
def _get_argnames(arguments): result = [pycompat.get_ast_arg_arg(node) for node in arguments.args if isinstance(node, pycompat.ast_arg_type)] if arguments.vararg: result.append(pycompat.get_ast_arg_arg(arguments.vararg)) if arguments.kwarg: result.append(pycompat.get_ast_arg_arg(arguments.kwarg)) return result
def get_param_names(self, special_args=True): # TODO: handle tuple parameters result = [pycompat.get_ast_arg_arg(node) for node in self.arguments.args if isinstance(node, pycompat.ast_arg_type)] if special_args: if self.arguments.vararg: result.append(pycompat.get_ast_arg_arg(self.arguments.vararg)) if self.arguments.kwarg: result.append(pycompat.get_ast_arg_arg(self.arguments.kwarg)) return result
def _arguments(self, node): children = [] args = list(node.args) defaults = [None] * (len(args) - len(node.defaults)) + list(node.defaults) for index, (arg, default) in enumerate(zip(args, defaults)): if index > 0: children.append(",") self._add_args_to_children(children, arg, default) if node.vararg is not None: if args: children.append(",") children.extend(["*", pycompat.get_ast_arg_arg(node.vararg)]) if node.kwarg is not None: if args or node.vararg is not None: children.append(",") children.extend(["**", pycompat.get_ast_arg_arg(node.kwarg)]) self._handle(node, children)
def _arguments(self, node): children = [] args = list(node.args) defaults = [None] * (len(args) - len(node.defaults)) + \ list(node.defaults) for index, (arg, default) in enumerate(zip(args, defaults)): if index > 0: children.append(',') self._add_args_to_children(children, arg, default) if node.vararg is not None: if args: children.append(',') children.extend(['*', pycompat.get_ast_arg_arg(node.vararg)]) if node.kwarg is not None: if args or node.vararg is not None: children.append(',') children.extend(['**', pycompat.get_ast_arg_arg(node.kwarg)]) self._handle(node, children)
def _FunctionDef(self, node): _ScopeVisitor._FunctionDef(self, node) if len(node.args.args) > 0: first = node.args.args[0] new_visitor = None if isinstance(first, pycompat.ast_arg_type): new_visitor = _ClassInitVisitor(self, pycompat.get_ast_arg_arg(first)) if new_visitor is not None: for child in ast.get_child_nodes(node): ast.walk(child, new_visitor)