o
    DDiR                     @   sX   d dl Z e jdk rd dlmZmZ nd dlmZmZ d dlmZ G dd dee ZdS )    N)   	   )IterableSequence)CSTNodeT_coc                   @   sT   e Zd ZU dZee ed< dee ddfddZde	defdd	Z
de	fd
dZdS )FlattenSentinela  
    A :class:`FlattenSentinel` may be returned by a :meth:`CSTTransformer.on_leave`
    method when one wants to replace a node with multiple nodes. The replaced
    node must be contained in a `Sequence` attribute such as
    :attr:`~libcst.Module.body`.  This is generally the case for
    :class:`~libcst.BaseStatement` and :class:`~libcst.BaseSmallStatement`.
    For example to insert a print before every return::

        def leave_Return(
            self, original_node: cst.Return, updated_node: cst.Return
        ) -> Union[cst.Return, cst.RemovalSentinel, cst.FlattenSentinel[cst.BaseSmallStatement]]:
            log_stmt = cst.Expr(cst.parse_expression("print('returning')"))
            return cst.FlattenSentinel([log_stmt, updated_node])

    Returning an empty :class:`FlattenSentinel` is equivalent to returning
    :attr:`cst.RemovalSentinel.REMOVE` and is subject to its requirements.
    nodesreturnNc                 C   s   t || _d S N)tupler   )selfr    r   Q/var/www/Datamplify/venv/lib/python3.10/site-packages/libcst/_flatten_sentinel.py__init__&   s   zFlattenSentinel.__init__idxc                 C   s
   | j | S r
   )r   )r   r   r   r   r   __getitem__)      
zFlattenSentinel.__getitem__c                 C   s
   t | jS r
   )lenr   )r   r   r   r   __len__,   r   zFlattenSentinel.__len__)__name__
__module____qualname____doc__r   r   __annotations__r   r   intr   r   r   r   r   r   r      s   
 r   )	sysversion_infotypingr   r   collections.abclibcst._typesr   r   r   r   r   r   <module>   s   
