o
    Ưh                     @   sH  d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
 ddlm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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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d'S )(z;All isort specific exception classes should be defined here    )partial)Path)AnyDictListTypeUnion   )profilesc                   @   s   e Zd ZdZdd ZdS )
ISortErrorzRBase isort exception object from which all isort sourced exceptions should inheritc                 C   s   t t| fi | jdfS )N )r   type__dict__selfr   r   M/var/www/Befach/backend/venv/lib/python3.10/site-packages/isort/exceptions.py
__reduce__   s   zISortError.__reduce__N)__name__
__module____qualname____doc__r   r   r   r   r   r   
   s    r   c                       &   e Zd ZdZdef fddZ  ZS )InvalidSettingsPathzQRaised when a settings path is provided that is neither a valid file or directorysettings_pathc                       t  d| d || _d S )Nz)isort was told to use the settings_path: zr as the base directory or file that represents the starting point of config file discovery, but it does not exist.)super__init__r   )r   r   	__class__r   r   r      s   

zInvalidSettingsPath.__init__r   r   r   r   strr   __classcell__r   r   r   r   r          r   c                       r   )ExistingSyntaxErrorszURaised when isort is told to sort imports within code that has existing syntax errors	file_pathc                    r   )NzHisort was told to sort imports within code that contains syntax errors: .r   r   r$   r   r$   r   r   r   r          
zExistingSyntaxErrors.__init__r   r   r   r   r   r#      r"   r#   c                       r   )IntroducedSyntaxErrorszQRaised when isort has introduced a syntax error in the process of sorting importsr$   c                    r   )NzTisort introduced syntax errors when attempting to sort the imports contained within r%   r&   r'   r   r   r   r   +   r(   zIntroducedSyntaxErrors.__init__r   r   r   r   r   r)   (   r"   r)   c                       *   e Zd ZdZdedef fddZ  ZS )FileSkippedz6Should be raised when a file is skipped for any reasonmessager$   c                    s   t  | || _|| _d S N)r   r   r,   r$   )r   r,   r$   r   r   r   r   6   s   
zFileSkipped.__init__r   r   r   r   r   r+   3       r+   c                       r*   )FileSkipCommentzFRaised when an entire file is skipped due to a isort skip file commentr$   kwargsc                       t  j| d|d d S )Nz. contains a file skip comment and was skipped.r$   r   r   r   r$   r0   r   r   r   r   ?   s   

zFileSkipComment.__init__r   r   r   r   r   r/   <   r.   r/   c                       r*   )FileSkipSettingzDRaised when an entire file is skipped due to provided isort settingsr$   r0   c                    r1   )NzV was skipped as it's listed in 'skip' setting or matches a glob in 'skip_glob' settingr2   r3   r4   r   r   r   r   H   s   
zFileSkipSetting.__init__r   r   r   r   r   r5   E   r.   r5   c                       r   )ProfileDoesNotExistz;Raised when a profile is set by the user that doesn't existprofilec                    s*   t  d| ddt d || _d S )NzSpecified profile of z% does not exist. Available profiles: ,r%   )r   r   joinr
   r7   )r   r7   r   r   r   r   S   s   
zProfileDoesNotExist.__init__r   r   r   r   r   r6   P   r"   r6   c                       s.   e Zd ZdZdedee f fddZ  ZS )SortingFunctionDoesNotExistz:Raised when the specified sorting function isn't available
sort_orderavailable_sort_ordersc                    s0   t  d| dd| d || _|| _d S )NzSpecified sort_order of z( does not exist. Available sort_orders: r8   r%   )r   r   r9   r;   r<   )r   r;   r<   r   r   r   r   ^   s   
z$SortingFunctionDoesNotExist.__init__)r   r   r   r   r    r   r   r!   r   r   r   r   r:   [       "r:   c                       r   )FormattingPluginDoesNotExistzERaised when a formatting plugin is set by the user that doesn't exist	formatterc                    r   )NzSpecified formatting plugin of z does not exist. )r   r   r?   )r   r?   r   r   r   r   j   s   
z%FormattingPluginDoesNotExist.__init__r   r   r   r   r   r>   g   r"   r>   c                       s6   e Zd ZdZdedeeee f f fddZ  Z	S )LiteralParsingFailurezwRaised when one of isorts literal sorting comments is used but isort can't parse the
    the given data structure.
    codeoriginal_errorc                    s*   t  d| d| d || _|| _d S )Nz(isort failed to parse the given literal z. It's important to note that isort literal sorting only supports simple literals parsable by ast.literal_eval which gave the exception of r%   )r   r   rA   rB   )r   rA   rB   r   r   r   r   t   s   
zLiteralParsingFailure.__init__)
r   r   r   r   r    r   	Exceptionr   r   r!   r   r   r   r   r@   o   s    *r@   c                       r*   )LiteralSortTypeMismatchzRaised when an isort literal sorting comment is used, with a type that doesn't match the
    supplied data structure's type.
    kindexpected_kindc                    s*   t  d| d| d || _|| _d S )Nz)isort was told to sort a literal of type z! but was given a literal of type r%   )r   r   rE   rF   )r   rE   rF   r   r   r   r      s   
z LiteralSortTypeMismatch.__init__)r   r   r   r   r   r   r!   r   r   r   r   rD   ~   s    rD   c                       r   )AssignmentsFormatMismatchzRaised when isort is told to sort assignments but the format of the assignment section
    doesn't match isort's expectation.
    rA   c                    r   )NzJisort was told to sort a section of assignments, however the given code:

z

Does not match isort's strict single line formatting requirement for assignment sorting:

{variable_name} = {value}
{variable_name2} = {value2}
...

)r   r   rA   )r   rA   r   r   r   r      s   
	z"AssignmentsFormatMismatch.__init__r   r   r   r   r   rG      s    rG   c                	       sT   e Zd ZdZededededefddZdeeeeef f f fd	d
Z	  Z
S )UnsupportedSettingszrRaised when settings are passed into isort (either from config, CLI, or runtime)
    that it doesn't support.
    namevaluesourcereturnc                 C   s   d|  d| d| dS )Nz	- z = z  (source: 'z')r   )rI   rJ   rK   r   r   r   _format_option   s   z"UnsupportedSettings._format_optionunsupported_settingsc                    s:   d  fdd| D }t d| d | _d S )N
c                 3   s&    | ]\}} j |fi |V  qd S r-   )rM   ).0rI   optionr   r   r   	<genexpr>   s    
z/UnsupportedSettings.__init__.<locals>.<genexpr>z6isort was provided settings that it doesn't support:

z}

For a complete and up-to-date listing of supported settings see: https://pycqa.github.io/isort/docs/configuration/options.
)r9   itemsr   r   rN   )r   rN   errorsr   r   r   r      s   
zUnsupportedSettings.__init__)r   r   r   r   staticmethodr    r   rM   r   r   r!   r   r   r   r   rH      s
    *rH   c                       s.   e Zd ZdZdeeef f fddZ  ZS )UnsupportedEncodingzJRaised when isort encounters an encoding error while trying to read a filefilenamec                    s   t  d|  || _d S )Nz#Unknown or unsupported encoding in )r   r   rW   )r   rW   r   r   r   r      s   
zUnsupportedEncoding.__init__)	r   r   r   r   r   r    r   r   r!   r   r   r   r   rV      r=   rV   c                       r*   )MissingSectionzQRaised when isort encounters an import that matches a section that is not definedimport_modulesectionc                    s   t  d| d| d d S )NzFound z import while parsing, but z was not included in the `sections` setting of your config. Please add it before continuing
See https://pycqa.github.io/isort/#custom-sections-and-ordering for more info.r3   )r   rY   rZ   r   r   r   r      s   zMissingSection.__init__r   r   r   r   r   rX      r.   rX   N)r   	functoolsr   pathlibr   typingr   r   r   r   r   r
   rC   r   r   r#   r)   r+   r/   r5   r6   r:   r>   r@   rD   rG   rH   rV   rX   r   r   r   r   <module>   s*    		