o
    no™i?  ã                   @   s¸   U d dl mZmZ d dlmZmZmZmZmZm	Z	 d dl
mZ dZeed< G dd„ deƒZG dd	„ d	eƒ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ÚOptionalÚSequenceÚTuple)Úexpand_tabsz
Ú_NEWLINE_CHARSc                   @   s   e Zd Zeƒ ZdS )ÚEOFSentinelN)Ú__name__Ú
__module__Ú__qualname__r   ÚEOF© r   r   úF/home/ubuntu/.local/lib/python3.10/site-packages/libcst/_exceptions.pyr      s    
r   c                   @   s   e Zd ZdZdS )ÚCSTLogicErrorz4General purpose internal error within LibCST itself.N)r   r   r   Ú__doc__r   r   r   r   r      s    r   ÚkwargsÚreturnÚParserSyntaxErrorc                 C   s   t di | ¤ŽS )Nr   )r   )r   r   r   r   Ú_parser_syntax_error_unpickle   s   r   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__-   s   
z!PartialParserSyntaxError.__init__)r   r   r   r   ÚstrÚ__annotations__r   r   r   r   r   r      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 )r   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   )Úsuperr   r   r   r    r!   r"   )r   r   r#   r!   r"   ©Ú	__class__r   r   r   P   s
   
zParserSyntaxError.__init__).r   .c                 C   s   t | j| j| j| jdœffS )N)r   r#   r!   r"   )r   r   r    r!   r"   ©r   r   r   r   Ú
__reduce__Y   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   r+   r   r   r   Ú__str__h   s   ÿþÿþÿzParserSyntaxError.__str__c                 C   s&   d| j ›d| j›d d| j›d S )NzParserSyntaxError(z, lines=[...], raw_line=z, zraw_column=ú))r   r!   r"   r'   r   r   r   Ú__repr__z   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)
        é   Ú
ú ú^N)r,   r-   Úlenr    Ústripr
   Úrstripr   )r   Údisplayed_lineÚdisplayed_columnÚformatted_source_liner   r   r   r+      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`.
        )r!   r'   r   r   r   r,   ¡   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`.
        r1   N)r    r!   r"   r5   r
   )r   Ú
prefix_strÚtab_adjusted_columnr   r   r   r-   ©   s   zParserSyntaxError.editor_column)r   r   r   r   r   r   r   Úintr   r	   r   Úobjectr(   r.   r0   Úpropertyr   r+   r,   r-   Ú__classcell__r   r   r%   r   r   1   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	   Úlibcst._tabsr
   r   r   r   r   Ú	Exceptionr   r   r   r   rA   r   r   r   r   Ú<module>   s     