o
    tBh                     @  sp  U d dl mZ d dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
mZmZmZmZ d dlmZmZmZ d dlmZ d dlmZmZ d dlmZ d d	lmZ d d
lmZ d dl m!Z!m"Z" d dl#m$Z% edZ&g dZ'de(d< ej)ej*iZ+de(d< G dd dZ,eee- e.e.e.e.e-e-e/ee f	 Z0de(d< G dd dZ1G dd dZ2G dd de3Z4d1d!d"Z5		d2d3d/d0Z6dS )4    )annotationsN)defaultdict)CallableNoReturnOptionalTextIOTupleTypeVar)FinalLiteral	TypeAlias)
errorcodes)IMPORT	ErrorCode)ErrorMessage)Options)Scope)DEFAULT_SOURCE_OFFSETis_typeshed_file)__version__T)z	@overloadGot:z	Expected:r
   allowed_duplicatesoriginal_error_codesc                   @  s   e Zd ZU dZded< dZdZded< dZded< dZded	< d
Z	d
Z
d
Zd
ZdZdZdZded< dZdZdZded< dZded< dZ		d$d%d"d#ZdS )&	ErrorInfoz)Representation of a single error message.list[tuple[str, int]]
import_ctx N
str | Nonemoduletypefunction_or_memberr   ErrorCode | NonecodeFztuple[str, int, int]origintargetfilestrtyplineintcolumnend_line
end_columnseveritymessageblockerbool	only_once
allow_dupstuple[str, int, int] | NonereturnNonec                 C  st   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|| _|| _|| _|| _|p3|||f| _|| _d S N)r   r&   r   r    r!   r)   r+   r,   r-   r.   r/   r#   r0   r2   r3   r$   r%   )selfr   r&   r   r(   r!   r)   r+   r,   r-   r.   r/   r#   r0   r2   r3   r$   r%    r9   b/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypy/errors.py__init__W   s"   
zErrorInfo.__init__NN)$r   r   r&   r'   r   r   r(   r   r!   r   r)   r*   r+   r*   r,   r*   r-   r*   r.   r'   r/   r'   r#   r"   r0   r1   r2   r1   r3   r1   r$   r4   r%   r   r5   r6   )__name__
__module____qualname____doc____annotations__r&   r   r    r!   r)   r+   r,   r-   r.   r/   r#   r0   r2   r3   r%   hiddenr;   r9   r9   r9   r:   r      s.   
 r   
_TypeAlias
ErrorTuplec                   @  sT   e Zd ZdZdddd"d
dZd#ddZd$ddZd%ddZd&ddZd'dd Z	d!S )(ErrorWatchera2  Context manager that can be used to keep track of new errors recorded
    around a given operation.

    Errors maintain a stack of such watchers. The handler is called starting
    at the top of the stack, and is propagated down the stack unless filtered
    out by one of the ErrorWatcher instances.
    F)filter_errorssave_filtered_errorserrorsErrorsrF   'bool | Callable[[str, ErrorInfo], bool]rG   r1   c                C  s*   || _ d| _|| _|rg | _d S d | _d S NF)rH   _has_new_errors_filter	_filtered)r8   rH   rF   rG   r9   r9   r:   r;      s   zErrorWatcher.__init__r5   c                 C  s   | j j|  | S r7   )rH   	_watchersappendr8   r9   r9   r:   	__enter__   s   zErrorWatcher.__enter__exc_typeobjectexc_valexc_tbLiteral[False]c                 C  s   | j j }|| ksJ dS rK   )rH   rO   pop)r8   rS   rU   rV   lastr9   r9   r:   __exit__   s   zErrorWatcher.__exit__r&   r'   infor   c                 C  sd   d| _ t| jtr| j}nt| jr| ||}n
tdt| j |r0| jdur0| j| |S )a  Handler called when a new error is recorded.

        The default implementation just sets the has_new_errors flag

        Return True to filter out the error, preventing it from being seen by other
        ErrorWatcher further down the stack and from being recorded by Errors
        Tzinvalid error filter: N)	rL   
isinstancerM   r1   callableAssertionErrorr    rN   rP   )r8   r&   r[   should_filterr9   r9   r:   on_error   s   
zErrorWatcher.on_errorc                 C     | j S r7   )rL   rQ   r9   r9   r:   has_new_errors      zErrorWatcher.has_new_errorslist[ErrorInfo]c                 C  s   | j d usJ | j S r7   )rN   rQ   r9   r9   r:   filtered_errors   s   zErrorWatcher.filtered_errorsN)rH   rI   rF   rJ   rG   r1   )r5   rE   )rS   rT   rU   rT   rV   rT   r5   rW   r&   r'   r[   r   r5   r1   r5   r1   )r5   rd   )
r=   r>   r?   r@   r;   rR   rZ   r`   rb   re   r9   r9   r9   r:   rE      s    



rE   c                   @  sX  e Zd ZU dZded< ded< ded< ded< d	Zd
ed< dZded< ded< ded< ded< ded< dZded< dZded< dZ	ded< dZ
ded< d	Zd
ed< d	Zded< dZg Zded< 											ddd*d+Zdd,d-Zdd.d/Zdd1d2Zdd3d4Z		ddd7d8Z	ddd;d<Zdd=d>Zdd?d@ZddAdBZddDdEZ		dddFd	ddd	dGd	d	dH	ddXdYZdd\d]Zdd^d_Zdd`daZddbdcZddddeZddgdhZ ddkdlZ!ddodpZ"ddqdrZ#ddtduZ$ddvdwZ%ddxdyZ&ddzd{Z'dd|d}Z(dd~dZ)ddddZ*dddZ+dddZ,dddZ-dddZ.dddZ/dddZ0dddZ1d	S )rI   zContainer for compile errors.

    This class generates and keeps tracks of compile errors and the
    current error context (nested imports).
    zdict[str, list[ErrorInfo]]error_info_mapset[str]has_blockersflushed_filesr   r   Nr   ignore_prefixr   r'   r&   zdict[str, dict[int, list[str]]]ignored_linesused_ignored_linesignored_filesonly_once_messagesFr1   show_error_contextshow_column_numbersshow_error_endshow_absolute_pathtarget_moduleScope | Nonescopezlist[ErrorWatcher]rO   show_error_codesprettyread_source(Callable[[str], list[str] | None] | Nonemany_errors_thresholdr*   optionsOptions | Noner5   r6   c
           
      C  sR   || _ || _|| _|| _|| _|| _|r|sJ d|| _|| _|	| _| 	  d S )Nz6Inconsistent formatting, must be prevented by argparse)
rq   rr   ry   rt   rz   rs   r{   r}   r~   
initialize)
r8   rq   rr   ry   rz   rs   r{   rt   r}   r~   r9   r9   r:   r;      s   zErrors.__init__c                 C  s^   i | _ t | _g | _d g| _i | _tdd | _t | _t | _	t | _
d | _d | _d| _d S )Nc                   S  s   t tS r7   )r   listr9   r9   r9   r:   <lambda>   s    z#Errors.initialize.<locals>.<lambda>F)rh   setrk   r   r!   rm   r   rn   ro   rp   rj   rw   ru   seen_import_errorrQ   r9   r9   r:   r     s   
zErrors.initializec                 C  s   |    d S r7   )r   rQ   r9   r9   r:   reset(  s   zErrors.resetprefixc                 C  s0   t j|}t j|dkr|t j7 }|| _dS )z4Set path prefix that will be removed from all paths.r   N)ospathnormpathbasenameseprl   )r8   r   r9   r9   r:   set_ignore_prefix+  s   

zErrors.set_ignore_prefixc                 C  s*   | j r	tj|S tj|}t|| jS r7   )rt   r   r   abspathr   remove_path_prefixrl   r8   r&   r9   r9   r:   simplify_path3  s   zErrors.simplify_pathr   r   c                 C  s   || _ || _|| _|| _dS )z/Set the path and module id of the current file.N)r&   ru   rw   r~   )r8   r&   r   r~   rw   r9   r9   r:   set_file:  s   

zErrors.set_filedict[int, list[str]]
ignore_allc                 C  s"   || j |< |r| j| d S d S r7   )rm   ro   add)r8   r&   rm   r   r9   r9   r:   set_file_ignored_linesI  s   
zErrors.set_file_ignored_linesc                 C  s   | j dur
| j  S | jS )zxRetrieves the current target from the associated scope.

        If there is no associated scope, use the target module.N)rw   current_targetru   rQ   r9   r9   r:   r   P  s   

zErrors.current_targetc                 C  ra   r7   )ru   rQ   r9   r9   r:   current_moduleX  rc   zErrors.current_modulec                 C  s   | j dd S )z$Return a copy of the import context.Nr   rQ   r9   r9   r:   import_context[  s   zErrors.import_contextctxc                 C  s   |dd | _ dS )z3Replace the entire import context with a new value.Nr   )r8   r   r9   r9   r:   set_import_context_  s   zErrors.set_import_contexterrorr   )	r0   r.   r&   r2   r3   origin_spanoffsetr,   r-   r)   r+   
int | Noner/   r#   r"   r0   r.   r2   r3   r   tuple[int, int] | Noner   r,   r-   c       	         C  s   | j r| j  }| j jdkrd}| j  }nd}d}|du r d}|du r/|dkr+d}n|d }|du r6| j}|r>d| | }|
du rF||f}
|du rL|}|pT|sStjnd}t|  || 	 ||||||||||||	| jg|
R | 
 d}| | dS )a;  Report message at the given line using the current error context.

        Args:
            line: line number of error
            column: column number of error
            message: message to report
            code: error code (defaults to 'misc'; not shown for notes)
            blocker: if True, don't continue analysis after this error
            severity: 'error' or 'note'
            file: if non-None, override current file as context
            only_once: if True, only report this exact message once per build
            allow_dups: if True, allow duplicate copies of this message (ignored if only_once)
            origin_span: if non-None, override current context as origin
                         (type: ignores have effect here)
            end_line: if non-None, override current context as end
        r   Nrx       )r$   r%   )rw   current_type_nameignoredcurrent_function_namer&   codesMISCr   r   r   r   add_error_info)r8   r)   r+   r/   r#   r0   r.   r&   r2   r3   r   r   r,   r-   r    functionr[   r9   r9   r:   reportc  sT   !
zErrors.reportr[   r   c                 C  sl   || j vsJ | ||rd S || jvrg | j|< | j| | |jr*| j| |jtu r4d| _	d S d S )NT)
rk   _filter_errorrh   rP   r0   rj   r   r#   r   r   )r8   r&   r[   r9   r9   r:   _add_error_info  s   



zErrors._add_error_infoc                 C  s@   t | j}|dkr|d8 }| j| }|||rdS |dks	dS )zy
        process ErrorWatcher stack from top to bottom,
        stopping early if error needs to be filtered out
        r   r   TF)lenrO   r`   )r8   r&   r[   iwr9   r9   r:   r     s   

zErrors._filter_errorc           
      C  s  |j \}}}| ||rd S |jsC|| jv r<t||d D ]}| ||| j| r;| j| | |jp5t	j
j  d S q|| jv rCd S |jrU|j| jv rNd S | j|j | jri|jturi|  rid|_| | | || | j|i |jg }|r|jrd|jj d}|jtv rt|j j}||v rd|jj dd }t|j|j|j|j|j|j|j|j |j!d|d d	d	d	d
}	| ||	 d S d S d S )Nr   TzError code "z'" not covered by "type: ignore" commentzError code changed to z; "type: ignore" comment zmay be out of datenoteF)r#   r0   r2   r3   )"r$   r   r0   rm   rangeis_ignored_errorrn   rP   r#   r   r   ro   r2   r/   rp   r   r   r   has_many_errorsrB   report_hidden_errorsr   getr)   r   r   r   r&   r   r    r!   r+   r,   r-   )
r8   r[   r&   r)   r,   
scope_lineignored_codesmsgold_coder   r9   r9   r:   r     sf   




zErrors.add_error_infoc                 C  sH   | j dk rdS t| j| j krdS tdd | j D | j kr"dS dS )Nr   FTc                 s      | ]}t |V  qd S r7   r   ).0rH   r9   r9   r:   	<genexpr>      z)Errors.has_many_errors.<locals>.<genexpr>)r}   r   rh   sumvaluesrQ   r9   r9   r:   r     s   
zErrors.has_many_errorsc                 C  s   d}|| j v r	d S | j | tdi d|jd|jd|jdd dd d|jd|jd	|jd
|j	ddd|dd ddddddd|j
d|j}| |j
d | d S )Nz\(Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)r   r&   r   r(   r!   r)   r+   r,   r-   r.   r   r/   r#   r0   Fr2   Tr3   r$   r%   r   r9   )rp   r   r   r   r&   r   r)   r+   r,   r-   r$   r%   r   )r8   r[   r/   new_infor9   r9   r:   r   !  sR   
	
zErrors.report_hidden_errorsignoresc                 C  s^   |j rdS |jr| |jsdS ||vrdS || sdS |jr-| |jr-|jj|| v S dS NFT)r0   r#   is_error_code_enabled)r8   r)   r[   r   r9   r9   r:   r   >  s   zErrors.is_ignored_error
error_coder   c                 C  sB   | j r| j j}| j j}nt }t }||v rdS ||v rdS |jS r   )r~   disabled_error_codesenabled_error_codesr   default_enabled)r8   r   current_mod_disabledcurrent_mod_enabledr9   r9   r:   r   M  s   
zErrors.is_error_code_enabledr   targetsc                 C  s   || j v r?g }d}| j | D ]}|j|vr || ||jO }q|jr*| j|j q|| j |< |sA|| jv rC| j| dS dS dS dS )z=Remove errors in specific fine-grained targets within a file.FN)	rh   r%   rP   r0   r2   rp   remover/   rj   )r8   r   r   
new_errorshas_blockerr[   r9   r9   r:   clear_errors_in_targets\  s   




zErrors.clear_errors_in_targetsc                 C  s  t | jr| jjnd |s|| jv rd S | j| }| j| }| D ]e\}}|| }t|t| }t|dkr>t|dkr>q!t|dkrKt|dkrKq!d}t|dkrdt|dkrddd	t
| d}d| d}	t|  ||  d d |d	|d	d
|	d ddd}
| ||
 q!d S )Nr   r   r   [, ]zUnused "type: ignorez	" commentrx   r   F)r   r~   abs_custom_typeshed_dirro   rm   rn   itemsr   r   joinsortedr   r   r   r   )r8   r&   rm   rn   r)   r   used_ignored_codesunused_ignored_codesunused_codes_messager/   r[   r9   r9   r:   generate_unused_ignore_errorsk  sH   


z$Errors.generate_unused_ignore_errorsis_warning_unused_ignoresc                 C  s   t | jr| jjnd |s|| jv rd S | j| }|r*t| \}}tjj	|v r*d S | j
|  D ]E\}}|r8q1|r?|| s?q1d}tt|| }|rTdd| d}d| }	t|  ||  d d |d|dd|	tjddd}
| ||
 q1d S )	Nr   z (consider "type: ignore[r   z]" instead)z)"type: ignore" comment without error coderx   r   F)r   r~   r   ro   rn   minr   r   FILEr#   rm   r   r   r   r   r   r   IGNORE_WITHOUT_CODEr   )r8   r&   r   rn   _
used_codesr)   r   
codes_hintr/   r[   r9   r9   r:   #generate_ignore_without_code_errors  sL   


z*Errors.generate_ignore_without_code_errorsc                 C  s   t dd | j D S )z(Return the number of generated messages.c                 s  r   r7   r   )r   xr9   r9   r:   r     r   z&Errors.num_messages.<locals>.<genexpr>)r   rh   r   rQ   r9   r9   r:   num_messages  s   zErrors.num_messagesc                 C  
   t | jS )z!Are there any generated messages?)r1   rh   rQ   r9   r9   r:   	is_errors     
zErrors.is_errorsc                 C  r   )z%Are the any errors that are blockers?)r1   rj   rQ   r9   r9   r:   is_blockers  r   zErrors.is_blockersc                 C  s4   | j D ]}| j| D ]}|jr|j    S q
qdS )zAReturn the module with a blocking error, or None if not possible.N)rj   rh   r0   r   )r8   r   errr9   r9   r:   blocker_module  s   
zErrors.blocker_modulec                 C  s
   || j v S )z(Are there any errors for the given file?)rh   r   r9   r9   r:   is_errors_for_file  r   zErrors.is_errors_for_fileT
use_stdoutr   c                 C  s   t |  ||  d)zpRaise a CompileError with the generated messages.

        Render the messages suitable for displaying.
        )r   module_with_blocker)CompileErrornew_messagesr   )r8   r   r9   r9   r:   raise_error  s   zErrors.raise_error
error_inford   source_lineslist[str] | None	list[str]c              
   C  s  g }dd |D }|  | |}| |}|D ]\	}}}}}	}
}}}d}|duro| jrV|dkrV|dkrV| d| dd|  }| jrU|dkrU|	dkrU|d| d|	 7 }n|dkrb| d| }n|}| d|
 d| }n|}| jr|r|
d	kr| d
|j d}|| | jr|
dkr|r|dkr||d  }|	 }|dk rt
|t
|  }t
|d| 	 }t
|d|	 	 }	|dt |  d}||kr|	|krdd|	| d   }|dt|  |  q|S )zReturn a string list that represents the error messages.

        Use a form suitable for displaying to the user. If self.pretty
        is True also append a relevant trimmed source code line (only for
        severity 'error').
        c                 S  s   g | ]}|j s|qS r9   )rB   )r   r[   r9   r9   r:   
<listcomp>  s    z*Errors.format_messages.<locals>.<listcomp>r   Nr   :r   : r   z  [r   r   r   ^~)render_messagessort_messagesremove_duplicatesrr   rs   ry   r#   rP   rz   
expandtabsr   lstripr   )r8   r   r   arH   r&   r)   r+   r,   r-   r.   r/   r3   r#   ssrclocsource_linesource_line_expandedmarkerr9   r9   r:   format_messages  sZ   	

zErrors.format_messagesc                 C  sJ   || j vrg S | j| d}| jr| jsJ | |}| | j | |S )zReturn a string list of new error messages from a given file.

        Use a form suitable for displaying to the user.
        N)rh   rk   r   rz   r{   r  )r8   r   r   r9   r9   r:   file_messages,  s   


zErrors.file_messagesc                 C  s2   g }| j  D ]}|| jvr|| | q|S )zReturn a string list of new error messages.

        Use a form suitable for displaying to the user.
        Errors from different files are ordered based on the order in which
        they first generated an error.
        )rh   keysrk   extendr  )r8   msgsr   r9   r9   r:   r   :  s   
zErrors.new_messagesc                 C  s   dd | j  D S )z0Return a set of all targets that contain errors.c                 S  s"   h | ]}|D ]}|j r|j qqS r9   )r%   )r   errsr[   r9   r9   r:   	<setcomp>K  s    z!Errors.targets.<locals>.<setcomp>)rh   r   rQ   r9   r9   r:   r   G  s   zErrors.targetsrH   list[ErrorTuple]c                 C  s  g }g }d}d}|D ]5}| j snO|j|kr`t|jd }|}|dkr`|j| \}	}
d}||k r2d}|dkr;|d7 }n|d7 }t|	| j}	|dddddd	||	|
|jdf	 |d8 }|dks#| |j	}| j sjn|j
|kst|j|kr|j
du r|jdu r||ddddd	d
|jdf	 nt||ddddd	d|j d|jdf	 n_|jdu r||ddddd	d|j
 d|jdf	 nE||ddddd	d|j
|j|jdf	 n/|j|kr|jdu r||ddddd	d
|jdf	 n||ddddd	d|j d|jdf	 t|jtr!|||j|j|j|j|j|jj|j|jf	 n|||j|j|j|j|j|j|j|jf	 |j}|j
}|j}q
|S )aQ  Translate the messages into a sequence of tuples.

        Each tuple is of form (path, line, col, severity, message, allow_dups, code).
        The rendered sequence includes information about error contexts.
        The path item may be None. If the line item is negative, the
        line number is not defined for the tuple.
        Nr   r   z${}:{}: note: In module imported herez{}:{}: note: ... from here,r   rx   r   zAt top level:z
In class "z":zIn function "zIn member "{}" of class "{}":)rq   r   r   r   rl   rP   formatr3   r   r&   r!   r    r\   r/   r   r)   r+   r,   r-   r.   valuer#   )r8   rH   resultprev_import_contextprev_function_or_member	prev_typeerY   r   r   r)   fmtr&   r9   r9   r:   r   O  s   






 zErrors.render_messagesc                 C  s   g }d}|t |k rk|}|d t |k rP||d  j|| jkrP||d  j|| jkrP|d7 }|d t |k rP||d  j|| jkrP||d  j|| jks,|d7 }t||| dd d}|| |t |k s
|S )zSort an array of error messages locally by line number.

        I.e., sort a run of consecutive messages with the same
        context by line number, but otherwise retain the general
        ordering of the messages.
        r   r   c                 S  s   | j | jfS r7   )r)   r+   )r   r9   r9   r:   r     s    z&Errors.sort_messages.<locals>.<lambda>)key)r   r   r&   r   r  )r8   rH   r  r   i0r   r9   r9   r:   r     s    
zErrors.sort_messagesc                 C  s  g }d}|t |k rd}d}|d }|| d s|dkrH|| d || d krH|| d  dkr4d}|d8 }|dkrH|| d || d ks(|d }|dkr|| d || d kr|| d || d kr|| d || d kr|| d d	kr|| d  tv s|| d  d
r|s|| d || d krd}n |d8 }|dkr|| d || d kr|| d || d ksh|s|||  |d7 }|t |k s
|S )z+Remove duplicates from a sorted error list.r   Fr         r   T   r   zdef )r   stripr   
startswithrP   )r8   rH   resr   dupconflicts_notesjr9   r9   r:   r     s<     8$8zErrors.remove_duplicates)	FFFFFNFrx   N)rq   r1   rr   r1   ry   r1   rz   r1   rs   r1   r{   r|   rt   r1   r}   r*   r~   r   r5   r6   )r5   r6   )r   r'   r5   r6   )r&   r'   r5   r'   r7   )
r&   r'   r   r   r~   r   rw   rv   r5   r6   )F)r&   r'   rm   r   r   r1   r5   r6   )r5   r   )r5   r   )r   r   r5   r6   )r)   r*   r+   r   r/   r'   r#   r"   r0   r1   r.   r'   r&   r   r2   r1   r3   r1   r   r   r   r*   r,   r   r-   r   r5   r6   )r&   r'   r[   r   r5   r6   rf   )r[   r   r5   r6   rg   )r)   r*   r[   r   r   r   r5   r1   )r   r   r5   r1   )r   r'   r   ri   r5   r6   )r&   r'   r5   r6   )r&   r'   r   r1   r5   r6   )r5   r*   )r&   r'   r5   r1   )T)r   r1   r5   r   )r   rd   r   r   r5   r   )r   r'   r5   r   )r5   r   )r5   ri   )rH   rd   r5   r  )rH   rd   r5   rd   )rH   r  r5   r  )2r=   r>   r?   r@   rA   rl   r&   rq   rr   rs   rt   ru   rw   r   rO   r;   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r   r   r   r   r9   r9   r9   r:   rI      s   
 	







	
T


C





*
4





@


 
rI   c                      s@   e Zd ZU dZded< dZdZded< 	dd fddZ  ZS )r   a  Exception raised when there is a compile error.

    It can be a parse, semantic analysis, type check or other
    compilation-related error.

    CompileErrors raised from an errors object carry all of the
    messages that have not been reported out by error streaming.
    This is patched up by build.build to contain either all error
    messages (if errors were streamed) or none (if they were not).

    r   messagesFNr   r   r   r1   r5   r6   c                   s(   t  d| || _|| _|| _d S )N
)superr;   r   r!  r   r   )r8   r!  r   r   	__class__r9   r:   r;   (  s   
zCompileError.__init__)FN)r!  r   r   r1   r   r   r5   r6   )	r=   r>   r?   r@   rA   r   r   r;   __classcell__r9   r9   r$  r:   r     s   
 r   r   r'   r   r   r5   c                 C  s&   |dur|  |r| t|d S | S )zIf path starts with prefix, return copy of path with the prefix removed.
    Otherwise, return path. If path is None, return None.
    N)r  r   )r   r   r9   r9   r:   r   1  s   r   r   	Exceptionr&   r)   r*   rH   r~   r   stdoutTextIO | Nonestderrr   c              
   C  s  |pt j}|p	t j}z| D ]}t| qW n ty2 } ztdt||d W Y d}~nd}~ww |rF|r@| d| d}	n| d}	nd}	t|	 dd|d |jr\td	|d ntd
|d tdt |d |j	rtd|d ddl	}
|

t  d  |jr| |js|j	std|	|d tdt dd }tt  d }td t|| D ]	}t|d qtt| j d|  |d t|	 d|d td)zZReport internal error and exit.

    This optionally starts pdb or shows a traceback.
    zFailed to dump errors:)r&   Nr   r   r   zerror: INTERNAL ERROR --zPlease try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-buildz<Please report a bug at https://github.com/python/mypy/issueszfIf this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issuesz	version: zDropping into pdbr      zO{}: note: please use --show-traceback to print a traceback when reporting a bugz"Traceback (most recent call last):r"  z": note: use --pdb to drop into pdb)sysr(  r*  r   printr'  reprshow_tracebackmypy_versionpdbpost_mortemexc_inforaise_exceptionsr  	tracebackextract_stack
extract_tbformat_listrstripr    r=   
SystemExit)r   r&   r)   rH   r~   r(  r*  r   r  r   r2  tbtb2r   r9   r9   r:   report_internal_error;  sb   


r>  )r   r'   r   r   r5   r'   r<   )r   r'  r&   r   r)   r*   rH   rI   r~   r   r(  r)  r*  r)  r5   r   )7
__future__r   os.pathr   r-  r6  collectionsr   typingr   r   r   r   r   r	   typing_extensionsr
   r   r   rC   mypyr   r   mypy.errorcodesr   r   mypy.message_registryr   mypy.optionsr   
mypy.scoper   	mypy.utilr   r   mypy.versionr   r1  r   r   rA   LITERAL_REQr   r   r   r'   r*   r1   rD   rE   rI   r'  r   r   r>  r9   r9   r9   r:   <module>   sD     e:      ]
