o
    DDi3                     @   s.  U d dl mZmZ d dlmZmZmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZmZ d dlmZ d dlmZ dZeed< d	Zeed
< dZeed< dZeed< G dd deZdeeef deeeeef  ef defddZdeddfddZeG dd deZeG dd deZ G dd deZ!dS )     )autoEnum)AnyCallablefinalIterableOptionalSequenceTupleUnion)ReservedString)PythonTokenTypes	TokenType)Token)expand_tabszend of file (EOF)_EOF_STRz	an indent_INDENT_STRza dedent_DEDENT_STRz
_NEWLINE_CHARSc                   @   s   e Zd Ze ZdS )EOFSentinelN)__name__
__module____qualname__r   EOF r   r   K/var/www/Datamplify/venv/lib/python3.10/site-packages/libcst/_exceptions.pyr      s    
r   encounteredexpectedreturnc                 C   s   t | ts| jtju rt}n| jtju rt}n| jtju r t	}nt
| j}t |tr.tg}n	tdd |D }t|dkrCd| dS t|dkrN|d }nd|d d	  d
|d	  }d| d| dS )Nc                 S   s*   g | ]}t |trt|jnt|jqS r   )
isinstancer   reprnamevalue).0elr   r   r   
<listcomp>,   s    z$get_expected_str.<locals>.<listcomp>
   zUnexpectedly encountered .   r   , z, or zEncountered z, but expected )r   r   typer   	ENDMARKERr   INDENTr   DEDENTr   r    stringsortedlenjoin)r   r   encountered_strexpected_namesexpected_strr   r   r   get_expected_str   s,   


 r6   kwargsParserSyntaxErrorc                 C   s   t di | S )Nr   )r8   )r7   r   r   r   _parser_syntax_error_unpickle?   s   r9   c                   @   s,   e Zd ZU dZeed< deddfddZdS )PartialParserSyntaxErrora  
    An internal exception that represents a partially-constructed
    :class:`ParserSyntaxError`. It's raised by our internal parser conversion functions,
    which don't always know the current line and column information.

    This partial object only contains a message, with the expectation that the line and
    column information will be filled in by :class:`libcst._base_parser.BaseParser`.

    This should never be visible to the end-user.
    messager   Nc                 C   s
   || _ d S N)r;   )selfr;   r   r   r   __init__R   s   
z!PartialParserSyntaxError.__init__)r   r   r   __doc__str__annotations__r>   r   r   r   r   r:   C   s   
 r:   c                
       s   e Zd ZU dZeed< ee ed< eed< eed< dedee dededdf
 fd	d
Zde	e
d e	edf f fddZdefddZdefddZedee fddZedefddZedefddZ  ZS )r8   a  
    Contains an error encountered while trying to parse a piece of source code. This
    exception shouldn't be constructed directly by the user, but instead may be raised
    by calls to :func:`parse_module`, :func:`parse_expression`, or
    :func:`parse_statement`.

    This does not inherit from :class:`SyntaxError` because Python's may raise a
    :class:`SyntaxError` for any number of reasons, potentially leading to unintended
    behavior.
    r;   _linesraw_line
raw_columnlinesr   Nc                   s,   t t| | || _|| _|| _|| _d S r<   )superr8   r>   r;   rB   rC   rD   )r=   r;   rE   rC   rD   	__class__r   r   r>   u   s
   
zParserSyntaxError.__init__).r8   .c                 C   s   t | j| j| j| jdffS )N)r;   rE   rC   rD   )r9   r;   rB   rC   rD   r=   r   r   r   
__reduce__~   s   zParserSyntaxError.__reduce__c                 C   s<   | j }d| j d| j d| j  |durd|  S d S )a.  
        A multi-line human-readable error message of where the syntax error is in their
        code. For example::

            Syntax Error @ 2:1.
            Incomplete input. Encountered end of file (EOF), but expected 'except', or 'finally'.

            try: pass
                     ^
        zSyntax Error @ :z.
Nz

 )contexteditor_lineeditor_columnr;   )r=   rM   r   r   r   __str__   s   zParserSyntaxError.__str__c                 C   s&   d| j d| jd d| jd S )NzParserSyntaxError(z, lines=[...], raw_line=r)   zraw_column=))r;   rC   rD   rI   r   r   r   __repr__   s   zParserSyntaxError.__repr__c                 C   s   | j }| j}|dkr1t| j|d   s1|d8 }t| j|d  }|dkr1t| j|d   rt| j|d   rVt| j|d  t}| dd|d   d S dS )aK  
        A formatted string containing the line of code with the syntax error (or a
        non-empty line above it) along with a caret indicating the exact column where
        the error occurred.

        Return ``None`` if there's no relevant non-empty line to show. (e.g. the file
        consists of only blank lines)
        r(   
 ^N)rN   rO   r1   rB   stripr   rstripr   )r=   displayed_linedisplayed_columnformatted_source_liner   r   r   rM      s   
zParserSyntaxError.contextc                 C   s   | j S )zs
        The expected one-indexed line in the user's editor. This is the same as
        :attr:`raw_line`.
        )rC   rI   r   r   r   rN      s   zParserSyntaxError.editor_linec                 C   s.   | j | jd  d| j }tt|}|d S )a  
        The expected one-indexed column that's likely to match the behavior of the
        user's editor, assuming tabs expand to 1-8 spaces. This is the column number
        shown when the syntax error is printed out with `str`.

        This assumes single-width characters. However, because python doesn't ship with
        a wcwidth function, it's hard to handle this properly without a third-party
        dependency.

        For a raw zero-indexed character offset without tab expansion, see
        :attr:`raw_column`.
        r(   N)rB   rC   rD   r1   r   )r=   
prefix_strtab_adjusted_columnr   r   r   rO      s   zParserSyntaxError.editor_column)r   r   r   r?   r@   rA   r	   intr>   r
   r   objectrJ   rP   rR   propertyr   rM   rN   rO   __classcell__r   r   rG   r   r8   V   s8   
 	
c                   @   s   e Zd ZdS )MetadataExceptionN)r   r   r   r   r   r   r   ra      s    ra   N)"enumr   r   typingr   r   r   r   r   r	   r
   r   $libcst._parser.parso.pgen2.generatorr   !libcst._parser.parso.python.tokenr   r   libcst._parser.types.tokenr   libcst._tabsr   r   r@   rA   r   r   r   r   r6   r9   	Exceptionr:   r8   ra   r   r   r   r   <module>   s2   (

' 