o
     wi?                     @   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   O/home/ubuntu/sommelier/.venv/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     