AsStringVisitor

class astroid.nodes.as_string.AsStringVisitor(indent: str = '    ')[source]

Bases: object

Visitor to render an Astroid node as a valid python code string

handle_functiondef(node: FunctionDef, keyword: str) str[source]

return a (possibly async) function definition node as string

visit_annassign(node: AnnAssign) str[source]

Return an nodes.AnnAssign node as string

visit_arguments(node: Arguments) str[source]

return an nodes.Arguments node as string

visit_assert(node: Assert) str[source]

return an nodes.Assert node as string

visit_assign(node: Assign) str[source]

return an nodes.Assign node as string

visit_assignattr(node: AssignAttr) str[source]

return an nodes.AssignAttr node as string

visit_assignname(node: AssignName) str[source]

return an nodes.AssignName node as string

visit_asyncfor(node: AsyncFor) str[source]
visit_asyncfunctiondef(node: AsyncFunctionDef) str[source]

return an nodes.AsyncFunction node as string

visit_asyncwith(node: AsyncWith) str[source]
visit_attribute(node: Attribute | AssignAttr | DelAttr) str[source]

return an nodes.Attribute node as string

visit_augassign(node: AugAssign) str[source]

return an nodes.AugAssign node as string

visit_await(node: Await) str[source]
visit_binop(node: BinOp) str[source]

return an nodes.BinOp node as string

visit_boolop(node: BoolOp) str[source]

return an nodes.BoolOp node as string

visit_break(node: Break) str[source]

return an nodes.Break node as string

visit_call(node: Call) str[source]

return an nodes.Call node as string

visit_classdef(node: ClassDef) str[source]

return an nodes.ClassDef node as string

visit_compare(node: Compare) str[source]

return an nodes.Compare node as string

visit_comprehension(node: Comprehension) str[source]

return an nodes.Comprehension node as string

visit_const(node: Const) str[source]

return an nodes.Const node as string

visit_continue(node: Continue) str[source]

return an nodes.Continue node as string

visit_decorators(node: Decorators) str[source]

return an nodes.Decorators node as string

visit_delattr(node: DelAttr) str[source]

return an nodes.DelAttr node as string

visit_delete(node: Delete) str[source]

return an nodes.Delete node as string

visit_delname(node: DelName) str[source]

return an nodes.DelName node as string

visit_dict(node: Dict) str[source]

return an nodes.Dict node as string

visit_dictcomp(node: DictComp) str[source]

return an nodes.DictComp node as string

visit_dictunpack(node: DictUnpack) str[source]
visit_empty(node: EmptyNode) str[source]

return an EmptyNode as string

visit_emptynode(node: EmptyNode) str[source]

dummy method for visiting an EmptyNode

visit_evaluatedobject(node: EvaluatedObject) str[source]
visit_excepthandler(node: ExceptHandler) str[source]
visit_expr(node: Expr) str[source]

return an nodes.Expr node as string

visit_for(node: For) str[source]

return an nodes.For node as string

visit_formattedvalue(node: FormattedValue) str[source]
visit_frozenset(node: objects.FrozenSet) str[source]
visit_functiondef(node: FunctionDef) str[source]

return an nodes.FunctionDef node as string

visit_generatorexp(node: GeneratorExp) str[source]

return an nodes.GeneratorExp node as string

visit_global(node: Global) str[source]

return an nodes.Global node as string

visit_if(node: If) str[source]

return an nodes.If node as string

visit_ifexp(node: IfExp) str[source]

return an nodes.IfExp node as string

visit_import(node: Import) str[source]

return an nodes.Import node as string

visit_importfrom(node: ImportFrom) str[source]

return an nodes.ImportFrom node as string

visit_interpolation(node: Interpolation) str[source]

Return an nodes.Interpolation node as string.

visit_joinedstr(node: JoinedStr) str[source]
visit_keyword(node: Keyword) str[source]

return an nodes.Keyword node as string

visit_lambda(node: Lambda) str[source]

return an nodes.Lambda node as string

visit_list(node: List) str[source]

return an nodes.List node as string

visit_listcomp(node: ListComp) str[source]

return an nodes.ListComp node as string

visit_match(node: Match) str[source]

Return an nodes.Match node as string.

visit_matchas(node: MatchAs) str[source]

Return an nodes..MatchAs node as string.

visit_matchcase(node: MatchCase) str[source]

Return an nodes.MatchCase node as string.

visit_matchclass(node: MatchClass) str[source]

Return an nodes..MatchClass node as string.

visit_matchmapping(node: MatchMapping) str[source]

Return an nodes..MatchMapping node as string.

visit_matchor(node: MatchOr) str[source]

Return an nodes.MatchOr node as string.

visit_matchsequence(node: MatchSequence) str[source]

Return an nodes.MatchSequence node as string.

static visit_matchsingleton(node: MatchSingleton) str[source]

Return an nodes.MatchSingleton node as string.

visit_matchstar(node: MatchStar) str[source]

Return an nodes..MatchStar node as string.

visit_matchvalue(node: MatchValue) str[source]

Return an nodes.MatchValue node as string.

visit_module(node: Module) str[source]

return an nodes.Module node as string

visit_name(node: Name) str[source]

return an nodes.Name node as string

visit_namedexpr(node: NamedExpr) str[source]

Return an assignment expression node as string, always parenthesized.

visit_nonlocal(node: Nonlocal) str[source]

return an nodes.Nonlocal node as string

visit_paramspec(node: ParamSpec) str[source]

return an nodes.ParamSpec node as string

visit_partialfunction(node: objects.PartialFunction) str[source]

Return an objects.PartialFunction as string.

visit_pass(node: Pass) str[source]

return an nodes.Pass node as string

visit_property(node: objects.Property) str[source]
visit_raise(node: Raise) str[source]

return an nodes.Raise node as string

visit_return(node: Return) str[source]

return an nodes.Return node as string

visit_set(node: Set) str[source]

return an nodes.Set node as string

visit_setcomp(node: SetComp) str[source]

return an nodes.SetComp node as string

visit_slice(node: Slice) str[source]

return an nodes.Slice node as string

visit_starred(node: Starred) str[source]

return Starred node as string

visit_subscript(node: Subscript) str[source]

return an nodes.Subscript node as string

visit_super(node: objects.Super) str[source]
visit_templatestr(node: TemplateStr) str[source]

Return an nodes.TemplateStr node as string.

visit_try(node: Try) str[source]

return an nodes.Try node as string

visit_trystar(node: TryStar) str[source]

return an nodes.TryStar node as string

visit_tuple(node: Tuple) str[source]

return an nodes.Tuple node as string

visit_typealias(node: TypeAlias) str[source]

return an nodes.TypeAlias node as string

visit_typevar(node: TypeVar) str[source]

return an nodes.TypeVar node as string

visit_typevartuple(node: TypeVarTuple) str[source]

return an nodes.TypeVarTuple node as string

visit_unaryop(node: UnaryOp) str[source]

return an nodes.UnaryOp node as string

visit_uninferable(node) str[source]
visit_unknown(node: Unknown) str[source]
visit_while(node: While) str[source]

return an nodes.While node as string

visit_with(node: With) str[source]

return an nodes.With node as string

visit_yield(node: Yield) str[source]

yield an ast.Yield node as string

visit_yieldfrom(node: YieldFrom) str[source]

Return an nodes.YieldFrom node as string.