o
    Lhx                     @  s   d dl mZ d dlmZ erd dlmZmZ G dd deZG dd de	Z
G dd	 d	e
eZG d
d deZG dd deZG dd deZG dd deZG dd deZG dd deeZG dd deZG dd deZG d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__ r   r   T/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/narwhals/exceptions.pyr   	       r   c                   @  s$   e Zd ZdZdddZd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.
    messagestrreturnNonec                 C  s
   || _ d S Nr   selfr   r   r   r   __init__   s   
zFormattedKeyError.__init__c                 C  s   | j S r   r   )r   r   r   r   __str__   s   zFormattedKeyError.__str__Nr   r   r   r   )r   r   )r	   r
   r   r   r   r   r   r   r   r   r      s    
r   c                      s>   e Zd ZdZd fddZedddZedddZ  ZS )ColumnNotFoundErrorz0Exception raised when column name isn't present.r   r   r   r   c                      || _ t | j  d S r   r   superr   r   	__class__r   r   r          zColumnNotFoundError.__init__missing_columnsIterable[str]available_columnsCollection[str]c                C  s"   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   r   r   r   'from_missing_and_available_column_names$   s
   z;ColumnNotFoundError.from_missing_and_available_column_namesc                 C  s   dt | d}t|S )NzOThe selected columns were not found.

Hint: Did you mean one of these columns: r'   )r)   r   )r*   r%   r   r   r   r   from_available_column_names.   s
   z/ColumnNotFoundError.from_available_column_namesr   )r#   r$   r%   r&   r   r   )r%   r&   r   r   )	r	   r
   r   r   r   classmethodr+   r,   __classcell__r   r   r    r   r      s    	r   c                   @  r   )ComputeErrorzHException raised when the underlying computation could not be evaluated.Nr   r   r   r   r   r/   9   r   r/   c                   @  r   )
ShapeErrorz_Exception raised when trying to perform operations on data structures with incompatible shapes.Nr   r   r   r   r   r0   =   r   r0   c                   @  r   )MultiOutputExpressionErrorzKException raised when using multi-output expression in unsupported context.Nr   r   r   r   r   r1   A   r   r1   c                   @  r   )DuplicateErrorz6Exception when duplicate column names are encountered.Nr   r   r   r   r   r2   E   r   r2   c                   @  r   )InvalidOperationErrorz+Exception raised during invalid operations.Nr   r   r   r   r   r3   I   r   r3   c                      s0   e Zd ZdZd fddZedddZ  ZS )InvalidIntoExprErrorz>Exception raised when object can't be converted to expression.r   r   r   r   c                   r   r   r   r   r    r   r   r   P   r"   zInvalidIntoExprError.__init__r*   typeinvalid_typec                 C  s   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`.)r4   )r*   r6   r   r   r   r   from_invalid_typeT   s   
z&InvalidIntoExprError.from_invalid_typer   )r*   r5   r6   r5   r   r4   )r	   r
   r   r   r   r-   r7   r.   r   r   r    r   r4   M   s
    r4   c                   @  r   )UnsupportedDTypeErrorz_Exception raised when trying to convert to a DType which is not supported by the given backend.Nr   r   r   r   r   r8   d   r   r8   c                   @  r   )NarwhalsUnstableWarningzRWarning issued when a method or function is considered unstable in the stable api.Nr   r   r   r   r   r9   h   r   r9   c                   @  s   e Zd ZdS )PerformanceWarningN)r	   r
   r   r   r   r   r   r:   l   s    r:   N)
__future__r   typingr   collections.abcr   r   
ValueErrorr   KeyErrorr   r   r/   r0   r1   r2   r3   	TypeErrorr4   r8   UserWarningr9   Warningr:   r   r   r   r   <module>   s     