
    }i                       d dl mZ d dlmZ erd dlmZmZ  G d de          Z G d de	          Z
 G d d	e
e          Z G d
 de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d dee          Z G d de          Z G d de          Z G d de          ZdS )    )annotations)TYPE_CHECKING)
CollectionIterablec                      e Zd ZdZdS )NarwhalsErrorz'Base class for all Narwhals exceptions.N__name__
__module____qualname____doc__     G/home/jrussi/.local/lib/python3.11/site-packages/narwhals/exceptions.pyr   r   	   s        1111r   r   c                  .    e Zd ZU dZded<   d	dZd
dZdS )FormattedKeyErrora7  KeyError with formatted error message.

    Python's `KeyError` has special casing around formatting
    (see https://bugs.python.org/issue2651). Use this class when the error
    message has newlines and other special format characters.
    Needed by https://github.com/tensorflow/tensorflow/issues/36857.
    strmessagereturnNonec                    || _         d S Nr   )selfr   s     r   __init__zFormattedKeyError.__init__   s    r   c                    | j         S r   r   )r   s    r   __str__zFormattedKeyError.__str__   s
    |r   Nr   r   r   r   )r   r   )r
   r   r   r   __annotations__r   r   r   r   r   r   r      sS           LLL        r   r   c                  `     e Zd ZU dZded<   d fdZedd            Zedd            Z xZ	S )ColumnNotFoundErrorz0Exception raised when column name isn't present.r   r   r   r   c                b    || _         t                                          | j                    d S r   r   superr   r   r   	__class__s     r   r   zColumnNotFoundError.__init__$   *    &&&&&r   missing_columnsIterable[str]available_columnsCollection[str]c               f    dt          |           dt          |           d}t          |          S )Nz&The following columns were not found: z+

Hint: Did you mean one of these columns: ?)sortedlistr!   )clsr(   r*   r   s       r   'from_missing_and_available_column_namesz;ColumnNotFoundError.from_missing_and_available_column_names(   sQ    
WVO5L5L W W<@AR<S<SW W W 	 #7+++r   c                F    dt          |           d}t          |          S )NzOThe selected columns were not found.

Hint: Did you mean one of these columns: r-   )r/   r!   )r0   r*   r   s      r   from_available_column_namesz/ColumnNotFoundError.from_available_column_names2   s;    
W<@AR<S<SW W W 	 #7+++r   r   )r(   r)   r*   r+   r   r!   )r*   r+   r   r!   )
r
   r   r   r   r   r   classmethodr1   r3   __classcell__r&   s   @r   r!   r!      s         ::LLL' ' ' ' ' ' , , , [, , , , [, , , , ,r   r!   c                      e Zd ZdZdS )ComputeErrorzHException raised when the underlying computation could not be evaluated.Nr	   r   r   r   r8   r8   =   s        RRRRr   r8   c                      e Zd ZdZdS )
ShapeErrorz_Exception raised when trying to perform operations on data structures with incompatible shapes.Nr	   r   r   r   r:   r:   A           iiiir   r:   c                      e Zd ZdZdS )MultiOutputExpressionErrorzKException raised when using multi-output expression in unsupported context.Nr	   r   r   r   r=   r=   E   s        UUUUr   r=   c                      e Zd ZdZdS )DuplicateErrorz6Exception when duplicate column names are encountered.Nr	   r   r   r   r?   r?   I   s        @@@@r   r?   c                      e Zd ZdZdS )InvalidOperationErrorz+Exception raised during invalid operations.Nr	   r   r   r   rA   rA   M   s        5555r   rA   c                  H     e Zd ZU dZded<   d fdZedd
            Z xZS )InvalidIntoExprErrorz>Exception raised when object can't be converted to expression.r   r   r   r   c                b    || _         t                                          | j                    d S r   r#   r%   s     r   r   zInvalidIntoExprError.__init__V   r'   r   r0   typeinvalid_typec                ,    d| d}t          |          S )NzBExpected an object which can be converted into an expression, got a  

Hint:
- if you were trying to select a column which does not have a string
  column name, then you should explicitly use `nw.col`.
  For example, `df.select(nw.col(0))` if you have a column named `0`.
- if you were trying to create a new literal column, then you 
  should explicitly use `nw.lit`.
  For example, `df.select(nw.lit(0))` if you want to create a new
  column with literal value `0`.)rC   )r0   rF   r   s      r   from_invalid_typez&InvalidIntoExprError.from_invalid_typeZ   s.    /Q] / / / 	 $G,,,r   r   )r0   rE   rF   rE   r   rC   )	r
   r   r   r   r   r   r4   rH   r5   r6   s   @r   rC   rC   Q   sn         HHLLL' ' ' ' ' ' - - - [- - - - -r   rC   c                      e Zd ZdZdS )UnsupportedDTypeErrorz_Exception raised when trying to convert to a DType which is not supported by the given backend.Nr	   r   r   r   rJ   rJ   j   r;   r   rJ   c                      e Zd ZdZdS )NarwhalsUnstableWarningzRWarning issued when a method or function is considered unstable in the stable api.Nr	   r   r   r   rL   rL   n   s        \\\\r   rL   c                      e Zd ZdS )PerformanceWarningN)r
   r   r   r   r   r   rN   rN   r   s          r   rN   N)
__future__r   typingr   collections.abcr   r   
ValueErrorr   KeyErrorr   r!   r8   r:   r=   r?   rA   	TypeErrorrC   rJ   UserWarningrL   WarningrN   r   r   r   <module>rW      sn   " " " " " "             5444444442 2 2 2 2J 2 2 2       $, , , , ,+] , , ,<S S S S S= S S Sj j j j j j j jV V V V V V V VA A A A A] A A A6 6 6 6 6M 6 6 6- - - - -9m - - -2j j j j jM j j j] ] ] ] ]k ] ] ] ' & & & & & & & & &r   