Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
462 lines (363 loc) · 20.2 KB

File metadata and controls

462 lines (363 loc) · 20.2 KB
Copy raw file
Download raw file
Outline
Edit and raw actions
title PyCommentGroup
sidebarTitle PyCommentGroup
icon
description A group of related symbols that represent a comment or docstring in Python For example: ``` # Comment 1 # Comment 2 # Comment 3 ``` would be 3 individual comments (accessible via `symbols`), but together they form a `CommentGroup` (accessible via `self`).

import {Parameter} from '/snippets/Parameter.mdx'; import {ParameterWrapper} from '/snippets/ParameterWrapper.mdx'; import {Return} from '/snippets/Return.mdx'; import {HorizontalDivider} from '/snippets/HorizontalDivider.mdx'; import {GithubLinkNote} from '/snippets/GithubLinkNote.mdx'; import {Attribute} from '/snippets/Attribute.mdx';

Inherits from

CommentGroup, SymbolGroup, Editable

Attributes

### extended SymbolGroup } description="Returns a SymbolGroup of all extended nodes associated with this element." />

extended_source

str } description="Returns the source text representation of all extended nodes." />

file

SourceFile } description="The file object that this Editable instance belongs to." />

file_node_id

NodeId } description=" " />

filepath

str } description="The file path of the file that this Editable instance belongs to." />

function_calls

list[ FunctionCall ] } description="Returns a list of all function calls contained within this expression." />

next_named_sibling

Editable | None } description="Returns the next named sibling of the last symbol in the group." />

next_sibling

Editable | None } description="Returns the next sibling of the last symbol in the symbol group." />

node_type

NodeType } description=" " />

parent

Editable } description=" " />

parent_class

Class | None } description="Find the class this node is contained in" />

parent_function

Function | None } description="Find the function this node is contained in" />

parent_statement

Statement | None } description="Find the statement this node is contained in" />

source

str } description="Returns the concatenated source code of all symbols in the group." />

symbols

list[ Editable ] } description="Returns the list of symbols in the group." />

text

str } description="Return the text content of all comments in the comment block." />

ts_node

TSNode } description=" " />

variable_usages

list[ Editable ] } description="Returns Editables for all TreeSitter node instances of variable usages within this node's" />

Methods

### ancestors Find all ancestors of the node of the given type. Does not return itself

<Return return_type={ <>list[ <a href="/api-reference/core/Editable" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Editable ]</> } description=""/>

edit

Replace the source of this node with new text.

str } description="The new source text to replace the current text with." defaultValue="" /> bool, optional } description="Adjusts the indentation of new_src to match the current text's indentation. Defaults to False." defaultValue="False" /> int, optional } description="Priority of the edit operation. Higher priority edits take precedence. Defaults to 0." defaultValue="0" /> bool, optional } description="Prevents duplicate edits at the same location. Defaults to True." defaultValue="True" />

<Return return_type={ None } description=""/>

edit_text

Replace the text content of a comment group with new text.

str } description="The new text content to replace the existing comment text." defaultValue="" />

<Return return_type={ None } description=""/>

find

Search for substrings in the given symbols that match strings_to_match.

list[str] | str } description="The string or list of strings to search for." defaultValue="" /> bool } description="If True, only return nodes that exactly match the query." defaultValue="False" />

<Return return_type={ <>list[ <a href="/api-reference/core/Editable" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Editable ]</> } description="A list of Editable objects representing each match found."/>

find_string_literals

Search for string literals matching given strings in the SymbolGroup.

list[str] } description="List of strings to search for in string literals." defaultValue="" /> bool, optional } description="If True, performs fuzzy matching instead of exact matching." defaultValue="False" />

<Return return_type={ <>list[ <a href="/api-reference/core/Editable" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Editable ]</> } description="List of Editable nodes representing the matching string literals found within the symbols."/>

flag

Adds a visual flag comment to the end of this Editable's source text.

<Return return_type={ <>CodeFlag[ <a href="/api-reference/python/PyCommentGroup" style={ {fontWeight: "inherit", fontSize: "inherit"} }>PyCommentGroup ]</> } description=""/>

get_variable_usages

Returns Editables for all TreeSitter nodes corresponding to instances of variable usage

str } description="The variable name to search for." defaultValue="" /> bool } description="If True, matches variables where var_name is a substring. If False, requires exact match. Defaults to False." defaultValue="False" />

<Return return_type={ <>list[ <a href="/api-reference/core/Editable" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Editable ]</> } description="List of Editable objects representing variable usage nodes matching the given name."/>

insert_after

Inserts source code after this node in the codebase.

str } description="The source code to insert." defaultValue="" /> bool, optional } description="Adjust indentation to match current text." defaultValue="False" /> bool, optional } description="Add a newline before the inserted code." defaultValue="True" /> int, optional } description="Priority of the edit operation." defaultValue="0" /> bool, optional } description="Deduplicate identical edits." defaultValue="True" />

<Return return_type={ None } description=""/>

insert_before

Inserts source code before this symbol group.

str } description="The source code to insert." defaultValue="" /> bool, optional } description="Whether to adjust the indentation of the inserted code to match the current code. Defaults to False." defaultValue="False" /> bool, optional } description="Whether to add a newline after the inserted code. Defaults to True." defaultValue="True" /> int, optional } description="The priority of this edit operation. Higher priority edits are applied first. Defaults to 0." defaultValue="0" /> bool, optional } description="Whether to prevent duplicate insertions of the same code. Defaults to True." defaultValue="True" />

<Return return_type={ None } description=""/>

is_wrapped_in

Check if this node is contained another node of the given class

<Return return_type={ bool } description=""/>

parent_of_type

Find the first ancestor of the node of the given type. Does not return itself

<Return return_type={ <><a href="/api-reference/core/Editable" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Editable | None</> } description=""/>

reduce_condition

Reduces an editable to the following condition

<Return return_type={ None } description=""/>

remove

Removes this node and its related extended nodes from the codebase.

bool, optional } description="Whether to delete related extended nodes like decorators and comments. Defaults to True." defaultValue="True" /> int, optional } description="Priority level of the removal operation. Defaults to 0." defaultValue="0" /> bool, optional } description="Whether to deduplicate removal operations. Defaults to True." defaultValue="True" />

<Return return_type={ None } description=""/>

replace

Replaces all instances of a string with a new string in all symbols within the group.

str } description="The string to be replaced." defaultValue="" /> str } description="The string to replace with." defaultValue="" /> int, optional } description="Maximum number of replacements to make. Defaults to -1 (replace all)." defaultValue="-1" /> int, optional } description="Priority of the replacement operation. Defaults to 0." defaultValue="0" />

<Return return_type={ int } description="Number of replacements made."/>

search

Searches for regex matches in the codebase.

str } description="The regular expression pattern to search for." defaultValue="" /> bool, optional } description="Whether to include string literals in the search. Defaults to True." defaultValue="True" /> bool, optional } description="Whether to include comments in the search. Defaults to True." defaultValue="True" />

<Return return_type={ <>list[ <a href="/api-reference/core/Editable" style={ {fontWeight: "inherit", fontSize: "inherit"} }>Editable ]</> } description="A list of Editable objects representing matched text nodes in the codebase."/>

to_google_docstring

Convert a comment group into a Google-style docstring.

PyFunction } description="The Python function whose signature will be used to extract parameter and return type information." defaultValue="" />

<Return return_type={ str } description="A formatted Google-style docstring string that includes the function's description, parameters, and return value information."/>

Morty Proxy This is a proxified and sanitized view of the page, visit original site.