def _merge_dicts(self, xs: Iterable[Union[ast.Call, ast.Dict]]) \ -> ast.Call: """Creates call of function for merging dicts.""" return ast.Call( func=ast.Name(id='_py_backwards_merge_dicts'), args=[ast.List(elts=list(xs))], keywords=[])
def visit_JoinedStr(self, node: ast.JoinedStr) -> ast.Call: self._tree_changed = True join_call = ast.Call(func=ast.Attribute(value=ast.Str(s=''), attr='join'), args=[ast.List(elts=node.values)], keywords=[]) return self.generic_visit(join_call) # type: ignore
def _prepare_lists(self, xs: List[Splitted]) -> Iterable[ListEntry]: """Wrap starred in list call and list elts to just List.""" for x in xs: if isinstance(x, ast.Starred): yield ast.Call(func=ast.Name(id='list'), args=[x.value], keywords=[]) elif x: yield ast.List(elts=x)
def visit_ClassDef(self, node: ast.ClassDef) -> ast.ClassDef: if node.keywords: metaclass = node.keywords[0].value node.bases = class_bases.get_body( metaclass=metaclass, # type: ignore bases=ast.List(elts=node.bases)) node.keywords = [] self._tree_changed = True return self.generic_visit(node) # type: ignore