Skip to main content
View Source on Github

Inherits from

Expression, Editable

Attributes

assignment_statements

assignments

attributes

comments

extended

extended_source

file

filepath

function_calls

if_blocks

level

local_var_assignments

parent

parent_block

parent_class

parent_function

parent_statement

resolved_value

return_statements

source

statements

symbol_statements

variable_usages

Methods

ancestors

Find all ancestors of the node of the given type. Does not return itself
View Source on Github

edit

Replace the source of this Editable with new_src.
View Source on Github

Parameters

find

Find and return matching nodes or substrings within an Editable instance.
View Source on Github

Parameters

find_string_literals

Returns a list of string literals within this node’s source that match any of the given
View Source on Github

Parameters

flag

Adds a visual flag comment to the end of this Editable’s source text.
View Source on Github

get_assignments

Returns a list of assignments with the specified variable name.
View Source on Github

Parameters

get_attributes

Returns attributes from the code block, with the option to include or exclude private
View Source on Github

Parameters

get_comment

Gets the first comment statement containing a specific text string.
View Source on Github

Parameters

get_local_var_assignment

Returns the first code statement that assigns a local variable with the specified name.
View Source on Github

Parameters

get_local_var_assignments

Returns all instances of local variable assignments that match the specified variable
View Source on Github

Parameters

get_statements

Returns all statements of a given type up to the specified block level.
View Source on Github

Parameters

get_variable_usages

Returns all instances of variable usages in a code block.
View Source on Github

Parameters

indent

Adjusts the indentation level of the entire code block.
View Source on Github

Parameters

insert_after

Inserts source code at the bottom of the code block.
View Source on Github

Parameters

insert_before

Inserts new source code at the top of the code block.
View Source on Github

Parameters

is_child_of

Checks if this node is a descendant of the given editable instance in the AST.
View Source on Github

is_wrapped_in

Check if this node is contained another node of the given class
View Source on Github

parent_of_type

Find the first ancestor of the node of the given type. Does not return itself
View Source on Github

parent_of_types

Find the first ancestor of the node of the given type. Does not return itself
View Source on Github

reduce_condition

Reduces an editable to the following condition
View Source on Github

remove

Deletes this Node and its related extended nodes (e.g. decorators, comments).
View Source on Github

Parameters

rename_variable_usages

Renames all instances of variable usages in the code block.
View Source on Github

Parameters

replace

Search and replace occurrences of text within this node’s source and its extended nodes.
View Source on Github

Parameters

Returns a list of all regex match of regex_pattern, similar to python’s re.search().
View Source on Github

Parameters

unwrap

Extracts a code block from its parent wrapper container by removing the wrapping
View Source on Github

wrap

Wraps a code block with a statement and indents it.
View Source on Github

Parameters