"""
This type stub file was generated by pyright.
"""

from functools import cached_property
from typing import TYPE_CHECKING
from tree_sitter import Node as TSNode
from graph_sitter.core.autocommit import reader
from graph_sitter.core.detached_symbols.function_call import FunctionCall
from graph_sitter.core.node_id_factory import NodeId
from graph_sitter.core.statements.statement import Statement
from graph_sitter.core.symbol_groups.expression_group import ExpressionGroup
from graph_sitter.python.interfaces.has_block import PyHasBlock
from graph_sitter.writer_decorators import apidoc
from graph_sitter.codebase.codebase_graph import CodebaseGraph
from graph_sitter.python.detached_symbols.code_block import PyCodeBlock

if TYPE_CHECKING:
    ...
@apidoc
class WithStatement(Statement["PyCodeBlock"], PyHasBlock):
    """Pythons implementation of the with statement.

    Examples:
    with feature_flag_enabled(...):
        # code block

    with open("file.txt") as file:
        # code block

    with (context_manager1 as var1,
          context_manager2 as var2,
          context_manager3 as var3):
        # code block

    Attributes:
        code_block: (PyCodeBlock) the code block of the with statement
        clause: the expression of the with clause
    """
    statement_type = ...
    code_block: PyCodeBlock[WithStatement]
    clause: ExpressionGroup
    def __init__(self, ts_node: TSNode, file_node_id: NodeId, G: CodebaseGraph, parent: PyCodeBlock, pos: int | None = ...) -> None:
        ...
    
    @property
    @reader
    def function_calls(self) -> list[FunctionCall]:
        """Returns all function calls in the code block and within the with clause.

        Retrieves all function calls present in both the statement's code block and its with clause.

        Returns:
            list[FunctionCall]: A list of all function calls in the code block and with clause, ordered by their position in the code.
        """
        ...
    
    @cached_property
    @reader
    def nested_code_blocks(self) -> list[PyCodeBlock]:
        """Returns all nested code blocks within the statement.

        Retrieves a list containing all code blocks that are nested within this statement. For a with statement, this includes its main code block.

        Returns:
            list[PyCodeBlock]: A list containing the code block associated with this statement.
        """
        ...
    


