# eric7.Plugins.CheckerPlugins.CodeStyleChecker.Simplify.ast_unparse

### Global Attributes

_ALL_QUOTES
_INFSTR
_MULTI_QUOTES
_SINGLE_QUOTES

### Classes

_Precedence | Precedence table that originated from python grammar.
_Unparser | Methods in this class recursively traverse an AST and output source code for the abstract syntax; original formatting is disregarded.
nullcontext | Context manager that does no additional processing.

### Functions

unparse |

## _Precedence

Precedence table that originated from python grammar.

### Derived from

IntEnum

### Class Attributes

AND
ARITH
ATOM
AWAIT
BAND
BOR
BXOR
CMP
EXPR
FACTOR
NOT
OR
POWER
SHIFT
TERM
TEST
TUPLE
YIELD

### Class Methods

None

### Methods

next |

### Static Methods

None

#### _Precedence.next

next()
Up

## _Unparser

Methods in this class recursively traverse an AST and output source code for the abstract syntax; original formatting is disregarded.

### Derived from

ast.NodeVisitor

### Class Attributes

binop
binop_precedence
binop_rassoc
boolop_precedence
boolops
cmpops
unop
unop_precedence
visit_Bytes
visit_Ellipsis
visit_NameConstant
visit_Num
visit_Str

### Class Methods

None

### Methods

_Unparser |
_for_helper |
_fstring_Constant |
_fstring_FormattedValue |
_fstring_JoinedStr |
_function_helper |
_str_literal_helper | Helper for writing string literals, minimizing escapes.
_write_constant |
_write_docstring |
_write_docstring_and_traverse_body |
_write_str_avoiding_backslashes | Write string literal value with a best effort attempt to avoid backslashes.
block | A context manager for preparing the source for blocks.
buffer |
buffer_writer |
delimit | A context manager for preparing the source for expressions.
delimit_if |
escape_char |
fill | Indent a piece of text and append it, according to the current indentation level
get_precedence |
get_raw_docstring | If a docstring node is found in the body of the *node* parameter, return that docstring node, None otherwise.
get_type_comment |
increasing_level_traverse |
interleave | Call f on each item in seq, calling inter() in between.
is_simple_tuple |
items_view | Traverse and separate the given *items* with a comma and append it to the buffer.
maybe_newline | Adds a newline if it isn't the start of generated source
require_parens | Shortcut to adding precedence related parens
set_precedence |
traverse |
visit | Outputs a source code string that, if converted back to an ast (using ast.parse) will generate an AST equivalent to *node*
visit_AnnAssign |
visit_Assert |
visit_Assign |
visit_AsyncFor |
visit_AsyncFunctionDef |
visit_AsyncWith |
visit_Attribute |
visit_AugAssign |
visit_Await |
visit_BinOp |
visit_BoolOp |
visit_Break |
visit_Call |
visit_ClassDef |
visit_Compare |
visit_Constant |
visit_Continue |
visit_Delete |
visit_Dict |
visit_DictComp |
visit_Ellipsis |
visit_ExceptHandler |
visit_Expr |
visit_For |
visit_FormattedValue |
visit_FunctionDef |
visit_FunctionType |
visit_GeneratorExp |
visit_Global |
visit_If |
visit_IfExp |
visit_Import |
visit_ImportFrom |
visit_JoinedStr |
visit_Lambda |
visit_List |
visit_ListComp |
visit_Module |
visit_Name |
visit_NamedExpr |
visit_Nonlocal |
visit_Pass |
visit_Raise |
visit_Return |
visit_Set |
visit_SetComp |
visit_Slice |
visit_Starred |
visit_Subscript |
visit_Try |
visit_Tuple |
visit_UnaryOp |
visit_While |
visit_With |
visit_Yield |
visit_YieldFrom |
visit_alias |
visit_arg |
visit_arguments |
visit_comprehension |
visit_keyword |
visit_withitem |
write | Append a piece of text
write_item |
write_key_value_pair |

### Static Methods

None

#### _Unparser (Constructor)

_Unparser(*, _avoid_backslashes=False)

#### _Unparser._for_helper

_for_helper(fill, node)

#### _Unparser._fstring_Constant

_fstring_Constant(node, write)

#### _Unparser._fstring_FormattedValue

_fstring_FormattedValue(node, write)

#### _Unparser._fstring_JoinedStr

_fstring_JoinedStr(node, write)

#### _Unparser._function_helper

_function_helper(node, fill_suffix)

#### _Unparser._str_literal_helper

_str_literal_helper(string, *, quote_types=_ALL_QUOTES, escape_special_whitespace=False)

Helper for writing string literals, minimizing escapes. Returns the tuple (string literal to write, possible quote types).

#### _Unparser._write_constant

_write_constant(value)

#### _Unparser._write_docstring

_write_docstring(node)

#### _Unparser._write_docstring_and_traverse_body

_write_docstring_and_traverse_body(node)

#### _Unparser._write_str_avoiding_backslashes

_write_str_avoiding_backslashes(string, *, quote_types=_ALL_QUOTES)

Write string literal value with a best effort attempt to avoid backslashes.

#### _Unparser.block

block(*, extra = None)

A context manager for preparing the source for blocks. It adds the character':', increases the indentation on enter and decreases the indentation on exit. If *extra* is given, it will be directly appended after the colon character.

#### _Unparser.buffer

buffer()

#### _Unparser.buffer_writer

buffer_writer(text)

#### _Unparser.delimit

delimit(start, end)

A context manager for preparing the source for expressions. It adds *start* to the buffer and enters, after exit it adds *end*.

#### _Unparser.delimit_if

delimit_if(start, end, condition)

#### _Unparser.escape_char

escape_char()

#### _Unparser.fill

fill(text="")

Indent a piece of text and append it, according to the current indentation level

#### _Unparser.get_precedence

get_precedence(node)

#### _Unparser.get_raw_docstring

get_raw_docstring(node)

If a docstring node is found in the body of the *node* parameter, return that docstring node, None otherwise.

Logic mirrored from ``_PyAST_GetDocString``.

#### _Unparser.get_type_comment

get_type_comment(node)

#### _Unparser.increasing_level_traverse

increasing_level_traverse()

#### _Unparser.interleave

interleave(inter, f, seq)

Call f on each item in seq, calling inter() in between.

#### _Unparser.is_simple_tuple

is_simple_tuple()

#### _Unparser.items_view

items_view(traverser, items)

Traverse and separate the given *items* with a comma and append it to the buffer. If *items* is a single item sequence, a trailing comma will be added.

#### _Unparser.maybe_newline

maybe_newline()

Adds a newline if it isn't the start of generated source

#### _Unparser.require_parens

require_parens(precedence, node)

Shortcut to adding precedence related parens

#### _Unparser.set_precedence

set_precedence(precedence, *nodes)

#### _Unparser.traverse

traverse(node)

#### _Unparser.visit

visit(node)

Outputs a source code string that, if converted back to an ast (using ast.parse) will generate an AST equivalent to *node*

#### _Unparser.visit_AnnAssign

visit_AnnAssign(node)

#### _Unparser.visit_Assert

visit_Assert(node)

#### _Unparser.visit_Assign

visit_Assign(node)

#### _Unparser.visit_AsyncFor

visit_AsyncFor(node)

#### _Unparser.visit_AsyncFunctionDef

visit_AsyncFunctionDef(node)

#### _Unparser.visit_AsyncWith

visit_AsyncWith(node)

#### _Unparser.visit_Attribute

visit_Attribute(node)

#### _Unparser.visit_AugAssign

visit_AugAssign(node)

#### _Unparser.visit_Await

visit_Await(node)

#### _Unparser.visit_BinOp

visit_BinOp(node)

#### _Unparser.visit_BoolOp

visit_BoolOp(node)

#### _Unparser.visit_Break

visit_Break(node)

#### _Unparser.visit_Call

visit_Call(node)

#### _Unparser.visit_ClassDef

visit_ClassDef(node)

#### _Unparser.visit_Compare

visit_Compare(node)

#### _Unparser.visit_Constant

visit_Constant(node)

#### _Unparser.visit_Continue

visit_Continue(node)

#### _Unparser.visit_Delete

visit_Delete(node)

#### _Unparser.visit_Dict

visit_Dict(node)

#### _Unparser.visit_DictComp

visit_DictComp(node)

#### _Unparser.visit_Ellipsis

visit_Ellipsis(node)

#### _Unparser.visit_ExceptHandler

visit_ExceptHandler(node)

#### _Unparser.visit_Expr

visit_Expr(node)

#### _Unparser.visit_For

visit_For(node)

#### _Unparser.visit_FormattedValue

visit_FormattedValue(node)

#### _Unparser.visit_FunctionDef

visit_FunctionDef(node)

#### _Unparser.visit_FunctionType

visit_FunctionType(node)

#### _Unparser.visit_GeneratorExp

visit_GeneratorExp(node)

#### _Unparser.visit_Global

visit_Global(node)

#### _Unparser.visit_If

visit_If(node)

#### _Unparser.visit_IfExp

visit_IfExp(node)

#### _Unparser.visit_Import

visit_Import(node)

#### _Unparser.visit_ImportFrom

visit_ImportFrom(node)

#### _Unparser.visit_JoinedStr

visit_JoinedStr(node)

#### _Unparser.visit_Lambda

visit_Lambda(node)

#### _Unparser.visit_List

visit_List(node)

#### _Unparser.visit_ListComp

visit_ListComp(node)

#### _Unparser.visit_Module

visit_Module(node)

#### _Unparser.visit_Name

visit_Name(node)

#### _Unparser.visit_NamedExpr

visit_NamedExpr(node)

#### _Unparser.visit_Nonlocal

visit_Nonlocal(node)

#### _Unparser.visit_Pass

visit_Pass(node)

#### _Unparser.visit_Raise

visit_Raise(node)

#### _Unparser.visit_Return

visit_Return(node)

#### _Unparser.visit_Set

visit_Set(node)

#### _Unparser.visit_SetComp

visit_SetComp(node)

#### _Unparser.visit_Slice

visit_Slice(node)

#### _Unparser.visit_Starred

visit_Starred(node)

#### _Unparser.visit_Subscript

visit_Subscript(node)

#### _Unparser.visit_Try

visit_Try(node)

#### _Unparser.visit_Tuple

visit_Tuple(node)

#### _Unparser.visit_UnaryOp

visit_UnaryOp(node)

#### _Unparser.visit_While

visit_While(node)

#### _Unparser.visit_With

visit_With(node)

#### _Unparser.visit_Yield

visit_Yield(node)

#### _Unparser.visit_YieldFrom

visit_YieldFrom(node)

#### _Unparser.visit_alias

visit_alias(node)

#### _Unparser.visit_arg

visit_arg(node)

#### _Unparser.visit_arguments

visit_arguments(node)

#### _Unparser.visit_comprehension

visit_comprehension(node)

#### _Unparser.visit_keyword

visit_keyword(node)

#### _Unparser.visit_withitem

visit_withitem(node)

#### _Unparser.write

write(text)

Append a piece of text

#### _Unparser.write_item

write_item()

#### _Unparser.write_key_value_pair

write_key_value_pair(v)
Up

## nullcontext

Context manager that does no additional processing.

Used as a stand-in for a normal context manager, when a particular block of code is only sometimes used with a normal context manager:

cm = optional_cm if condition else nullcontext() with cm: # Perform operation, using optional_cm if condition is True

### Derived from

AbstractContextManager

### Class Attributes

None

### Class Methods

None

### Methods

nullcontext |
__enter__ |
__exit__ |

### Static Methods

None

#### nullcontext (Constructor)

nullcontext(enter_result=None)

#### nullcontext.__enter__

__enter__()

#### nullcontext.__exit__

__exit__(*excinfo)
Up

## unparse

unparse(ast_obj)
Up