
    X-Ph2                       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	 d dl
mZmZmZmZmZmZ d dlmZm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! d dl"m#Z# d dl$m%Z%m&Z& d dl'm(Z)  ed          Z*ej+        ej,        hZ-de.d<   ej/        ej0        ej1        ej2        ej3        ej4        ej5        hZ6de.d<   g dZ7de.d<   dZ8de.d<   ej9        ej/        ej:        ej/        iZ;de.d<    G d d          Z<e=ee>         e?e?e?e?e>e>e@ee         f	         ZAde.d<    G d d          ZB G d d          ZC G d d eD          ZEd:d&ZF	 	 d;d<d3ZG G d4 d5          ZHe=e>e?e?f         ZId=d9ZJdS )>    )annotationsN)defaultdict)Iterable)CallableFinalNoReturnOptionalTextIOTypeVar)Literal	TypeAlias)
errorcodes)ErrorFormatter)IMPORTIMPORT_NOT_FOUNDIMPORT_UNTYPED	ErrorCodemypy_error_codes)Options)Scope)DEFAULT_SOURCE_OFFSETis_typeshed_file)__version__Tr   SHOW_NOTE_CODESHIDE_LINK_CODES)z	@overloadGot:z	Expected:zExpected setter type:allowed_duplicatesz.https://mypy.rtfd.io/en/stable/_refs.html#codeBASE_RTD_URLoriginal_error_codesc                      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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, Iterable[int]]origintarget)r,   r-   priorityfilestrtyplineintcolumnend_line
end_columnseveritymessageblockerbool	only_once
allow_dups tuple[str, Iterable[int]] | Noner.   returnNonec                  || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        || _        || _        || _        |p||gf| _        || _        || _        d S N)r$   r/   r'   r(   r)   r2   r4   r5   r6   r7   r8   r+   r9   r;   r<   r,   r-   r.   )selfr$   r/   r'   r1   r)   r2   r4   r5   r6   r7   r8   r+   r9   r;   r<   r,   r-   r.   s                      K/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/errors.py__init__zErrorInfo.__init__n   s    , %		"4	 $ 	"$.v     )&r$   r#   r/   r0   r'   r&   r1   r&   r)   r&   r2   r3   r4   r3   r5   r3   r6   r3   r7   r0   r8   r0   r+   r*   r9   r:   r;   r:   r<   r:   r,   r=   r-   r&   r.   r3   r>   r?   )__name__
__module____qualname____doc____annotations__r/   r'   r(   r)   r2   r4   r5   r6   r7   r8   r+   r9   r;   r<   r-   hiddenrD    rE   rC   r"   r"   2   s        33 &%%% D F D &('''' D F H J H G "D!!!! G I J &%%% F F( 48!)'! '! '! '! '! '! '! '!rE   r"   
_TypeAlias
ErrorTuplec                  L    e Zd ZdZddddddZddZd dZd!dZd"dZ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filter_deprecatederrorsErrorsrQ   'bool | Callable[[str, ErrorInfo], bool]rR   r:   rS   r>   r?   c               T    || _         d| _        || _        || _        |rg nd | _        d S NF)rT   _has_new_errors_filter_filter_deprecated	_filtered)rB   rT   rQ   rR   rS   s        rC   rD   zErrorWatcher.__init__   s7     $$"37K1UQUrE   c                D    | j         j                            |            | S rA   )rT   	_watchersappendrB   s    rC   	__enter__zErrorWatcher.__enter__   s     $$T***rE   exc_typeobjectexc_valexc_tbLiteral[False]c                R    | j         j                                        }|| k    sJ dS rX   )rT   r^   pop)rB   rb   rd   re   lasts        rC   __exit__zErrorWatcher.__exit__   s*    {$((**t||||urE   r/   r0   infor"   c                t   |j         t          j        k    r| j        S d| _        t          | j        t                    r| j        }nOt          | j                  r|                     ||          }n$t          dt          | j                             |r!| j        | 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: )r+   codes
DEPRECATEDr[   rY   
isinstancerZ   r:   callableAssertionErrorr(   r\   r_   )rB   r/   rk   should_filters       rC   on_errorzErrorWatcher.on_error   s     9(((**#dlD)) 	P LMMdl## 	P LLt44MM !N$t|:L:L!N!NOOO 	(T^7N!!$'''rE   c                    | j         S rA   )rY   r`   s    rC   has_new_errorszErrorWatcher.has_new_errors   s    ##rE   list[ErrorInfo]c                "    | j         J | j         S rA   )r\   r`   s    rC   filtered_errorszErrorWatcher.filtered_errors   s    ~)))~rE   N)
rT   rU   rQ   rV   rR   r:   rS   r:   r>   r?   )r>   rP   )rb   rc   rd   rc   re   rc   r>   rf   r/   r0   rk   r"   r>   r:   r>   r:   )r>   rv   )
rF   rG   rH   rI   rD   ra   rj   rs   ru   rx   rL   rE   rC   rP   rP      s          BG%*"'V V V V V V      
   0$ $ $ $     rE   rP   c                  V   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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 <   d	d	d!d~d*Zdd+Zdd,Zdd.Zdd/Z	 ddd1Z	 ddd4Zdd6Zdd7Zdd8Zdd9Zdd;Z	 ddd<d	ddd	d=d	d	d>	ddOZddRZddSZddTZddUZddVZ ddXZ!dd[Z"dd^Z#dd_Z$ddaZ%ddbZ&ddcZ'dddZ(ddeZ)ddfZ*ddgZ+dddkZ,ddqZ-dddtZ.dduZ/ddvZ0ddwZ1ddzZ2dd{Z3dd|Z4dd}Z5d	S )rU   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%   r0   r/   zdict[str, dict[int, list[str]]]ignored_lineszdict[str, set[int]]skipped_linesused_ignored_linesignored_filesonly_once_messagesFr:   show_error_contextshow_column_numbersshow_error_endshow_absolute_pathtarget_moduleScope | Nonescopezlist[ErrorWatcher]r^   )read_sourcehide_error_codesoptionsr   r   (Callable[[str], list[str] | None] | Noner   bool | Noner>   r?   c               j    || _         ||n|j        | _        || _        |                                  d S rA   )r   r   r   
initialize)rB   r   r   r   s       rC   rD   zErrors.__init__$  sD      0 <'BZ 	 'rE   c                :   i | _         t                      | _        g | _        d g| _        i | _        i | _        t          d           | _        t                      | _	        t                      | _
        t                      | _        d | _        d | _        d| _        d S )Nc                 *    t          t                    S rA   )r   listrL   rE   rC   <lambda>z#Errors.initialize.<locals>.<lambda>:  s    k$6G6G rE   F)r|   setr   r$   r)   r   r   r   r   r   r   r~   r   r   seen_import_errorr`   s    rC   r   zErrors.initialize3  s      UU#'&"-.G.G"H"H UU"%%%EE
!!&rE   c                .    |                                   d S rA   )r   r`   s    rC   resetzErrors.resetB  s    rE   prefixc                    t           j                            |          }t           j                            |          dk    r|t           j        z  }|| _        dS )z4Set path prefix that will be removed from all paths.r%   N)ospathnormpathbasenamesepr   )rB   r   s     rC   set_ignore_prefixzErrors.set_ignore_prefixE  sL    !!&))7F##r))bfF#rE   c                    | j         j        rt          j                            |          S t          j                            |          }t          || j                  S rA   )r   r   r   r   abspathr   remove_path_prefixr   rB   r/   s     rC   simplify_pathzErrors.simplify_pathM  sL    <* 	@7??4(((7##D))D%dD,>???rE   r'   c                >    || _         || _        || _        || _        dS )z/Set the path and module id of the current file.N)r/   r   r   r   )rB   r/   r'   r   r   s        rC   set_filezErrors.set_fileT  s%     	#
rE   dict[int, list[str]]
ignore_allc                V    || j         |<   |r| j                            |           d S d S rA   )r   r   add)rB   r/   r   r   s       rC   set_file_ignored_lineszErrors.set_file_ignored_linesc  s@     $14  	)""4(((((	) 	)rE   set[int]c                    || j         |<   d S rA   )r   )rB   r/   r   s      rC   set_skipped_lineszErrors.set_skipped_linesj  s    #04   rE   c                P    | j         | j                                         S | j        S )zxRetrieves the current target from the associated scope.

        If there is no associated scope, use the target module.)r   current_targetr   r`   s    rC   r   zErrors.current_targetm  s)     :!:,,...!!rE   c                    | j         S rA   )r   r`   s    rC   current_modulezErrors.current_moduleu  s    !!rE   c                4    | j                                         S )z$Return a copy of the import context.)r$   copyr`   s    rC   import_contextzErrors.import_contextx  s    ##%%%rE   ctxc                8    |                                 | _        dS )z3Replace the entire import context with a new value.N)r   r$   )rB   r   s     rC   set_import_contextzErrors.set_import_context|  s    ((**rE   errorr   )	r9   r7   r/   r;   r<   origin_spanoffsetr5   r6   r2   r3   r4   
int | Noner8   r+   r*   r9   r7   r;   r<   r   Iterable[int] | Noner   r5   r6   c       	        H   | j         rE| j                                         }| j         j        dk    rd}| j                                         }nd}d}|d}||dk    rd}n|dz   }|| j        }|rd|z  |z   }|
|g}
||}|p|st
          j        nd}t          di d|                                 d|d| 	                                d	|d
|d|d|d|d|d|d|d|d|d|d|	d| j        |
f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   N    r$   r/   r'   r1   r)   r2   r4   r5   r6   r7   r8   r+   r9   r;   r<   r,   r-   rL   )r   current_type_nameignoredcurrent_function_namer/   rm   MISCr"   r   r   r   add_error_info)rB   r2   r4   r8   r+   r9   r7   r/   r;   r<   r   r   r5   r6   r(   functionrk   s                    rC   reportzErrors.report  s   B : 	://11Dz!A%%z7799HHDH>F||

#aZ
<9D 	-FlW,G&KH<';

t 
 
 
**,,,

 &&(((
 	

  (x
 
 6
 X
 "z
 X
 G
 
 G
  i
 "z
  I{++!
" &&(((#
& 	D!!!!!rE   rk   r"   c                <   || j         vsJ |                     ||          rd S || j        vr
g | j        |<   | j        |                             |           |j        r| j                            |           |j        t          t          t          fv r	d| _        d S d S )NT)r   _filter_errorr|   r_   r9   r~   r   r+   r   r   r   r   )rB   r/   rk   s      rC   _add_error_infozErrors._add_error_info  s    4----- dD)) 	Ft***(*D%D!((...< 	(!!$'''91ABBB%)D""" CBrE   c                    t          | j                  }|dk    r0|dz  }| j        |         }|                    ||          rdS |dk    0dS )zy
        process ErrorWatcher stack from top to bottom,
        stopping early if error needs to be filtered out
        r   r   TF)lenr^   rs   )rB   r/   rk   iws        rC   r   zErrors._filter_error  s^    
 !eeFAq!Azz$%% t	 !ee
 urE   c                   |j         \  }}|                     ||          rd S |j        s|| j        v r|D ]}}|                     ||| j        |                   rY|j        pt          j        }|                     |          s d S | j	        |         |         
                    |j                    d S ~|| j        v rd S |j        r/|j        | j        v rd S | j                            |j                   | j        rK|j        t"          t$          t&          fvr0|                                 rd|_        |                     |           |                     ||           | j                            |i                               |j        g           }|r|j        rd|j        j         d}|j        t4          v r.t4          |j                 j        }||v rd|j        j         ddz   }t7          |j        |j        |j        |j        |j         |j        |j!        |j"        |j#        d|d ddd	          }	|                     ||	           | j$        j%        r| j$        j&        s|j        |j        tN          vr|j        j        tP          v rd
tR           d|j        j         d}
|
| j        v rd S | j                            |
           t7          di d|j        d|j        d|j        d|j        d|j         d|j        d|j!        d|j"        d|j#        ddd|
d|j        dddddddd}|                     ||           d S d S d S d S d S d S )NTz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$   r/   r'   r1   r)   r2   r4   r5   r6   r7   r8   r+   r9   r;   r<   zSee -z for more infor$   r/   r'   r1   r)   r2   r4   r5   r6   r7   r8   r+   r9   r;   r<   r.      rL   )*r,   r   r9   r   is_ignored_errorr+   rm   r   is_error_code_enabledr   r_   r   r;   r8   r   r   r   r   r   r   has_many_errorsrK   report_hidden_errorsr   getr2   r    r"   r$   r/   r'   r(   r)   r4   r5   r6   r   show_error_code_linksr   r   r   r   )rB   rk   r/   lines
scope_lineerr_codeignored_codesmsgold_coder   r8   s              rC   r   zErrors.add_error_info  sE   ke
 dD)) 	F| 	t))) #( 	 	J,,Zt?QRV?WXX #'9#:
#99(CC # #FF/5jAHHWWW t)))> 	6|t666#''555"	,	&.:J!KKK$$&& L DK%%d+++T4(((*..tR88<<TYKK 	-TY 	- YXXXCy000 0	:?},,ZZZZ./  ?Y{I#'#:Y{?   D"   t,,,L.	-L1	- 	%	00	"222J\JJDINJJJG$111#''000   ??YY {{ II	
 $(#:#: YY {{   ??     YY  $ !5  !D$   t,,,,,;	- 	- 	- 	- &%0022rE   c                    | j         j        dk     rdS t          | j                  | j         j        k    rdS t	          d | j                                        D                       | j         j        k    rdS dS )Nr   FTc              3  4   K   | ]}t          |          V  d S rA   r   ).0rT   s     rC   	<genexpr>z)Errors.has_many_errors.<locals>.<genexpr>]  s(      GGFGGGGGGrE   )r   many_errors_thresholdr   r|   sumvaluesr`   s    rC   r   zErrors.has_many_errorsW  s~    <-115t"##t|'III4GG$*=*D*D*F*FGGGGG|12 2 4urE   c                j   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'   r1   r)   r2   r4   r5   r6   r7   r   r8   r+   r9   Fr;   Tr<   r,   r-   r   rL   )r   r   r"   r$   r/   r'   r2   r4   r5   r6   r,   r-   r   )rB   rk   r8   new_infos       rC   r   zErrors.report_hidden_errorsc  sJ   ! 	 d---F##G,,, 
 
 


 ;;
 	

  $t
 
 ;;
 ]]
 
 V
 G
 
 E
 d
 u
  ;;!
" ;;#
& 	T[^X66666rE   ignoresc                6   |j         rdS |j        r|                     |j                  sdS ||vrdS ||         sdS |j        rU|                     |j                  r;|j        j        ||         v p&|j        j        d uo|j        j        j        ||         v S dS NFT)r9   r+   r   sub_code_of)rB   r2   rk   r   s       rC   r   zErrors.is_ignored_error  s    < 	59 	T77	BB 	4w5t} 	49 	33DI>> 		'$-/ @9(4 @I).'$-?
 urE   
error_coder   c                    | j         r| j         j        }| j         j        }nt                      }t                      }||v rdS ||v rdS |j        |j        |v rdS |j        S r   )r   disabled_error_codesenabled_error_codesr   r   default_enabled)rB   r   current_mod_disabledcurrent_mod_enableds       rC   r   zErrors.is_error_code_enabled  s    < 	(#'<#D "&,"B#&55 "%%%---5...4#/J4JNb4b4b5--rE   r   targetsc                H   || j         v rg }d}| j         |         D ]Q}|j        |vr |                    |           ||j        z  }+|j        r| j                            |j                   R|| j         |<   |s'|| j        v r | j                            |           dS dS dS dS )z=Remove errors in specific fine-grained targets within a file.FN)	r|   r-   r_   r9   r;   r   remover8   r~   )rB   r   r   
new_errorshas_blockerrk   s         rC   clear_errors_in_targetszErrors.clear_errors_in_targets  s    4&&&JK+D1 A A;g--%%d+++4</KK^ A+224<@@@(2D% /44+<#<#<!((..... '&/ /#<#<rE   c                R   t          | j        r| j        j        nd |          s	|| j        v rd S | j        |         }| j        |         }|                                D ]H\  }}|| j        |         v rt          j	        j
        |v r*||         }t          |          t          |          z
  }|s|rV|r|s[d}t          |          dk    r(|r&dd                    t          |                     d}d| d}	|D ]E}
t          |          t          j        |
         z  }|r|	dd                    |           d	|
 d
z  }	Ft!          |                                 ||                                 d d |d|dd|	t          j	        ddd          }|                     ||           Jd S )Nr%   r   [, ]zUnused "type: ignorez	" commentz, use narrower [z] instead of [z] coder   r   Fr   )r   r   abs_custom_typeshed_dirr   r   r   itemsr   rm   UNUSED_IGNOREr+   r   r   joinsortedsub_code_mapr"   r   r   r   )rB   r/   r   r   r2   r   used_ignored_codesunused_ignored_codesunused_codes_messager8   unusednarrowerrk   s                rC   generate_unused_ignore_errorsz$Errors.generate_unused_ignore_errors  s%   T\[T\AAW[]abb	t)))F*40!4T:#0#6#6#8#8 (	- (	-D-t)$///"'=88!3D!9#&}#5#5<N8O8O#O   %7  %9 #% =!!A%%*>%'U499V<P5Q5Q+R+R'U'U'U$L-ALLLG. d d122U5G5OO dc$))H2E2EccU[ccccG..00**,,#' (   D"   t,,,,Q(	- (	-rE   is_warning_unused_ignoresc                   t          | j        r| j        j        nd |          s	|| j        v rd S | j        |         }|r9t          |                                          \  }}t          j        j	        |v rd S | j
        |                                         D ]\  }}|r|r	||         sd}t          t          ||                             }|rdd                    |           d}d| }	t          |                                 ||                                 d d |d|dd|	t          j        ddd	          }
|                     ||
           d S )
Nr%   z (consider "type: ignore[r  z]" instead)z)"type: ignore" comment without error coder   r   Fr   )r   r   r  r   r   minr  rm   FILEr+   r   r  r   r  r"   r   r   IGNORE_WITHOUT_CODEr   )rB   r/   r  r   _
used_codesr2   r   
codes_hintr8   rk   s              rC   #generate_ignore_without_code_errorsz*Errors.generate_ignore_without_code_errors  s    T\[T\AAW[]abb	t)))F!4T:  	 2 8 8 : :;;MAzz*,,#'#5d#;#A#A#C#C !	- !	-D-  ) 1CD1I J"3'9$'?#@#@AAM _^=9Q9Q^^^
N*NNG..00**,,#' .   D"   t,,,,C!	- !	-rE   c                b    t          d | j                                        D                       S )z(Return the number of generated messages.c              3  4   K   | ]}t          |          V  d S rA   r   )r   xs     rC   r   z&Errors.num_messages.<locals>.<genexpr>  s(      @@a3q66@@@@@@rE   )r   r|   r   r`   s    rC   num_messageszErrors.num_messages  s.    @@4#6#=#=#?#?@@@@@@rE   c                *    t          | j                  S )z!Are there any generated messages?)r:   r|   r`   s    rC   	is_errorszErrors.is_errors  s    D'(((rE   c                *    t          | j                  S )z%Are the any errors that are blockers?)r:   r~   r`   s    rC   is_blockerszErrors.is_blockers!  s    D%&&&rE   c                ^    | j         D ]$}| j        |         D ]}|j        r|j        c c S %dS )zAReturn the module with a blocking error, or None if not possible.N)r~   r|   r9   r'   )rB   r   errs      rC   blocker_modulezErrors.blocker_module%  sZ    % 	& 	&D*40 & &; &:%%%%%&& trE   c                &    || j         v o|| j        vS )z(Are there any errors for the given file?)r|   r   r   s     rC   is_errors_for_filezErrors.is_errors_for_file-  s    t**Mt4;M/MMrE   c                `    | j         | j        v rdS | j        D ]}|j        du r
|j         dS dS )a7  Should we generate simple/fast error messages?

        Return True if errors are not shown to user, i.e. errors are ignored
        or they are collected for internal use only.

        If True, we should prefer to generate a simple message quickly.
        All normal errors should still be reported.
        TNF)r/   r   r^   rZ   r\   )rB   _watchers     rC   prefer_simple_messageszErrors.prefer_simple_messages1  sM     9***4 	 	H4''H,>,FtturE   T
use_stdoutr   c                n    t          |                                 ||                                           )zpRaise a CompileError with the generated messages.

        Render the messages suitable for displaying.
        )r)  module_with_blocker)CompileErrornew_messagesr#  )rB   r)  s     rC   raise_errorzErrors.raise_errorC  s:     JDL_L_LaLa
 
 
 	
rE   error_tupleslist[ErrorTuple]source_lineslist[str] | None	list[str]c           
        g }|D ]\	  }}}}}}	}
}}d}|d| j         j        r=|dk    r7|dk    r1| d| dd|z    }| j         j        r|dk    r|dk    r|d| d| z  }n|dk    r| d| }n|}| d|	 d|
 }n|
}| j        s|r|	dk    s	|t          v r| d|j         d	}|                    |           | j         j        r|	d
k    r|r|dk    r||dz
           }|                                }|dk     r1t          |          t          |
                                          z
  }t          |d|                                                   }t          |d|                                                   }|                    dt          z  |z              d}||k    r||k    rdd||z
  dz
  z   }|                    dt          |z   z  |z              |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').
        r%   Nr   :r   : r   z  [r  r   r   ^~)r   r   r   r   r   r+   r_   pretty
expandtabsr   lstripr   )rB   r/  r1  ar/   r2   r4   r5   r6   r7   r8   r<   r+   ssrclocsource_linesource_line_expandedmarkers                     rC   format_messageszErrors.format_messagesN  s     4	N 4	N 

A<3 "		fPQkk $::t::a&j::F|2 >x1}}WX"=h"="="="==QYY $--t--FF!F6666W66)** ''4?+B+B ))TY)))HHQKKK|" Nw&&<&D1HH".tax"8K+6+A+A+C+C(zz!$[!1!1C8J8J8L8L4M4M!M !WfW!5!@!@!B!BCCF!$[*%=%H%H%J%J!K!KJ HHS#88;OOPPP F4''J,?,?!FSJ,?!,C%D!F!FHHS$9F$BCfLMMMrE   	formatterErrorFormatter | Nonec                   || j         vrg S | j         |         }d |D             }|                     |                     |                    }|                     |          }t	          |          }fd|D             S | j                            |           d}| j        j        rI| j	        rB| 
                    |          }|r| 	                    |          }n| 	                    |          }|                     ||          S )zReturn a string list of new error messages from a given file.

        Use a form suitable for displaying to the user.
        c                     g | ]}|j         	|S rL   )rK   )r   rk   s     rC   
<listcomp>z(Errors.file_messages.<locals>.<listcomp>  s    EEEtEdEEErE   Nc                :    g | ]}                     |          S rL   )report_error)r   r"  rC  s     rC   rG  z(Errors.file_messages.<locals>.<listcomp>  s'    BBBCI**3//BBBrE   )r|   render_messagessort_messagesremove_duplicatescreate_errorsr   r   r   r9  r   find_shadow_file_mappingrB  )rB   r   rC  
error_infor/  rT   r1  mapped_paths     `     rC   file_messageszErrors.file_messages  s'   
 t***I(.
EEzEEE
++D,>,>z,J,JKK--l;; "<00FBBBB6BBBBt$$$< 	64#3 	6 77==K 6#//<<#//55##L,???rE   c                l    | j         j        dS | j         j        D ]}|d         |k    r
|d         c S dS )zAReturn the shadow file path for a given source file path or None.Nr   r   )r   shadow_file)rB   r   r   s      rC   rN  zErrors.find_shadow_file_mapping  sJ    <#+4) 	 	Att||t trE   c                    g }| j                                         D ]3}|| j        vr(|                    |                     |                     4|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.
        )r|   keysr   extendrQ  )rB   msgsr   s      rC   r-  zErrors.new_messages  s[     ',,.. 	6 	6D4---D..t44555rE   c                H    d | j                                         D             S )z0Return a set of all targets that contain errors.c                4    h | ]}|D ]}|j         	|j         S rL   )r-   )r   errsrk   s      rC   	<setcomp>z!Errors.targets.<locals>.<setcomp>  sG     
 
 
 T
 
EIUYU`
K
 
 
 
rE   )r|   r   r`   s    rC   r   zErrors.targets  s2    
 
$($7$>$>$@$@
 
 
 	
rE   rT   rv   c                8   g }g }d}d}|D ]}| j         j        sn|j        |k    rt          |j                  dz
  }|}|dk    r|j        |         \  }	}
d}||k     rd}|dk    r|dz  }n|dz  }t	          |	| j                  }	|                    dddddd	|                    |	|
          |j        df	           |dz  }|dk    | 	                    |j
                  }| j         j        snN|j        |k    s|j        |k    r|j        Y|j        %|                    |ddddd	d
|j        df	           n|                    |ddddd	d|j         d|j        df	           n|j        -|                    |ddddd	d|j         d|j        df	           n|                    |ddddd	d                    |j        |j                  |j        df	           nb|j        |k    rW|j        $|                    |ddddd	d
|j        df	           n,|                    |ddddd	d|j         d|j        df	           |                    ||j        |j        |j        |j        |j        |j        |j        |j        f	           |j        }|j        }|j        }|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,r5  r   r   zAt top level:z
In class "z":zIn function "zIn member "{}" of class "{}":)r   r   r$   r   r   r   r_   formatr<   r   r/   r)   r(   r2   r4   r5   r6   r7   r8   r+   )rB   rT   resultprev_import_contextprev_function_or_member	prev_typeeri   r   r   r2   fmtr/   s                rC   rJ  zErrors.render_messages  s    $&57.2 $	 j	 j	A<2 !4441<((1,1ff!"aJD$@C4xx:1uus
s
 .dD4FGGDMMr2r2vszz$7M7Mq|]ab   FA 1ff" %%af--D <2 =%)@@@AFiDWDW'/v~!2r2r6?ALZ^_     $ " " " " & 7QV 7 7 7 ! $
    v~ $ " " " " & H0D H H H ! $
     $ " " " " & ? F F$%$8!&!" !" !" $    9$$6>MMr2r2vVZ[    MMr2r2v7NAF7N7N7NPQP\^bc   MMFHJLJILF
   #$,&'&:#IIrE   c                N   g }d}|t          |          k     r|}|dz   t          |          k     r||dz            j        ||         j        k    rx||dz            j        ||         j        k    rY|dz  }|dz   t          |          k     r>||dz            j        ||         j        k    r||dz            j        ||         j        k    Y|dz  }t          |||         d           }|                     |          }|                    |           |t          |          k     |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                    | j         | j        fS rA   )r2   r4   r  s    rC   r   z&Errors.sort_messages.<locals>.<lambda>[  s    AFAH3E rE   key)r   r$   r/   r  sort_within_contextrV  rB   rT   r_  r   i0r<  s         rC   rK  zErrors.sort_messagesF  s3    #%#f++ooB AF##1q5M,q	0DDD1q5M&&).88Q	 AF##1q5M,q	0DDD1q5M&&).88 FA vbd|)E)EFFFA((++AMM! #f++oo rE   c                   g }d}|t          |          k     r|}|dz   t          |          k     rS||dz            j        ||         j        k    r3||dz            j        ||         j        k    r||dz            j        ||         j        k    r||dz            j        ||         j        k    r||dz            j        ||         j        k    r|dz  }|dz   t          |          k     r||dz            j        ||         j        k    r|||dz            j        ||         j        k    r]||dz            j        ||         j        k    r>||dz            j        ||         j        k    r||dz            j        ||         j        k    |dz  }t          |||         d           }|                    |           |t          |          k     |S )zFor the same location decide which messages to show first/last.

        Currently, we only compare within the same error code, to decide the
        order of various additional notes.
        r   r   c                    | j         S rA   )r.   rg  s    rC   r   z,Errors.sort_within_context.<locals>.<lambda>w  s    1: rE   rh  )r   r2   r4   r5   r6   r+   r  rV  rk  s         rC   rj  zErrors.sort_within_context`  s    #f++ooB AF##1q5M&&).881q5M(F1I,<<<1q5M*fQi.@@@1q5M,q	0DDD1q5M&&).88Q AF##1q5M&&).881q5M(F1I,<<<1q5M*fQi.@@@1q5M,q	0DDD1q5M&&).88 FA vbd|)=)=>>>AMM!! #f++oo" rE   c                2   g }d}|t          |          k     rd}d}|dz
  }||         d         s|dk    rm||         d         ||         d         k    rO||         d                                         dk    rd}|dz  }|dk    r||         d         ||         d         k    O|dz
  }|dk    r1||         d         ||         d         k    r||         d         ||         d         k    r||         d         ||         d         k    r||         d         d	k    r'||         d                                         t          v sV||         d                                                             d
          r|s!||         d         ||         d         k    rd}nG|dz  }|dk    r<||         d         ||         d         k    r||         d         ||         d         k    |s|                    ||                    |dz  }|t          |          k     |S )z+Remove duplicates from a sorted error list.r   Fr         r   T   r   zdef )r   stripr   
startswithr_   )rB   rT   resr   dupconflicts_notesjs          rC   rL  zErrors.remove_duplicates{  s6    "#f++ooC#OAA!9Q< 1ff11!=!=ay|))++v55*.FA 1ff11!=!= E1ff11!=!=&)A,RXYZR[\]R^B^B^q	!q	!44 $AYq\V33q	!8J8J8L8LPb8b8b &q	! 2 2 4 4 ? ? G G 9cL[ 9c #1IaLF1IaL88"FA 1ff11!=!=&)A,RXYZR[\]R^B^B^  &

6!9%%%FA9 #f++oo: 
rE   )r   r   r   r   r   r   r>   r?   )r>   r?   )r   r0   r>   r?   )r/   r0   r>   r0   rA   )
r/   r0   r'   r&   r   r   r   r   r>   r?   )F)r/   r0   r   r   r   r:   r>   r?   )r/   r0   r   r   r>   r?   )r>   r&   )r>   r#   )r   r#   r>   r?   )r2   r3   r4   r   r8   r0   r+   r*   r9   r:   r7   r0   r/   r&   r;   r:   r<   r:   r   r   r   r3   r5   r   r6   r   r>   r?   )r/   r0   rk   r"   r>   r?   ry   )rk   r"   r>   r?   rz   )r2   r3   rk   r"   r   r   r>   r:   )r   r   r>   r:   )r   r0   r   r}   r>   r?   )r/   r0   r>   r?   )r/   r0   r  r:   r>   r?   )r>   r3   )r/   r0   r>   r:   )T)r)  r:   r>   r   )r/  r0  r1  r2  r>   r3  )r   r0   rC  rD  r>   r3  )r   r0   r>   r&   )r>   r3  )r>   r}   )rT   rv   r>   r0  )rT   rv   r>   rv   )rT   r0  r>   r0  )6rF   rG   rH   rI   rJ   r   r/   r   r   r   r   r   r   r   r^   rD   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.  rB  rQ  rN  r-  r   rJ  rK  rj  rL  rL   rE   rC   rU   rU      s          /...   &%%% !%M$$$$ DNNNN 3222 '&&& 8777  !     %$$$$ !&%%%% !N      %$$$$
 !%M$$$$E $&I&&&& AE(,     ' ' ' '   $ $ $ $@ @ @ @ VZ      RW) ) ) ) )1 1 1 1" " " "" " " "& & & &% % % % "&R"  ,0#!%R" R" R" R" R" R"h* * * *   f- f- f- f-P
 
 
 
7 7 7 7:   &. . . ."/ / / /0- 0- 0- 0-d2- 2- 2- 2-hA A A A) ) ) )' ' ' '   N N N N   $	
 	
 	
 	
 	
? ? ? ?B@ @ @ @ @:      
 
 
 
y y y yv   4   6! ! ! ! ! !rE   rU   c                  F     e Zd ZU dZded<   dZdZded<   	 dd fdZ x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).

    r3  messagesFNr&   r+  r)  r:   r>   r?   c                    t                                          d                    |                     || _        || _        || _        d S )N
)superrD   r  rz  r)  r+  )rB   rz  r)  r+  	__class__s       rC   rD   zCompileError.__init__  sE     	8,,--- $#6   rE   )FN)rz  r3  r)  r:   r+  r&   r>   r?   )	rF   rG   rH   rI   rJ   r)  r+  rD   __classcell__)r~  s   @rC   r,  r,    sz         
 
 J&***** `d7 7 7 7 7 7 7 7 7 7 7rE   r,  r   r0   r   r&   r>   c                b    |,|                      |          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)rt  r   )r   r   s     rC   r   r     s5     doof55CKKMM""rE   r"  	Exceptionr/   r2   r3   rT   r   r   stdoutTextIO | Nonestderrr   c                   |pt           j        }|pt           j        }	 |                                D ]}t	          |           n6# t
          $ r)}t	          dt          |          |           Y d}~nd}~ww xY w|r|r	| d| d}	n| d}	nd}	t	          |	 dd|           |j        rt	          d	|           nt	          d
|           t	          dt           |           |j	        rAt	          d|           ddl	}
|

                    t          j                    d                    |j        r| |j        s,|j	        s$t	          d                    |	          |           nt          j                    dd         }t          j        t          j                    d                   }t	          d           t          j        ||z             D ]$}t	          |                    d                     %t	          t'          |           j         d|  |           t	          |	 d|           t+          d          )zZReport internal error and exit.

    This optionally starts pdb or shows a traceback.
    zFailed to dump errors:)r/   Nr5  r6  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(   rF   
SystemExit)r"  r/   r2   rT   r   r  r  r   rc  r   r  tbtb2r=  s                 rC   report_internal_errorr    s    !szF!szF>&&(( 	 	C#JJJJ	 > > >&Qf=========>   	!''t'''FF[[[FF 
+++	*      
LSYZZZZZK	
 	
 	
 	

 

$l
$
$62222 { +!////


q)***  	! J{ 	''-vf~~    $&&ss+"3<>>!#4552333&rCx00 	" 	"A!((4..!!!!c#,,s,,6::::;;;&IIII Q--s   &A 
A8A33A8c                      e Zd ZddZdS )	MypyError	file_pathr0   r2   r3   r4   r8   	errorcoder*   r7   Literal['error', 'note']r>   r?   c                h    || _         || _        || _        || _        || _        || _        g | _        d S rA   )r  r2   r4   r8   r  r7   hints)rB   r  r2   r4   r8   r  r7   s          rC   rD   zMypyError.__init__  s9     #	"  "


rE   N)r  r0   r2   r3   r4   r3   r8   r0   r  r*   r7   r  r>   r?   )rF   rG   rH   rD   rL   rE   rC   r  r    s(        # # # # # #rE   r  r/  r0  list[MypyError]c           
     z   g }i }| D ]}|\	  }}}}}}}	}}
||dv sJ |dk    rb|||f}|                     |          }|+t          ||||	|
d          }|                    |           d|j                            |	           t          ||||	|
d          }|                    |           |||f}|||<   |S )N)r   r   r   )r7   r   )r   r  r_   r  )r/  rT   latest_error_at_locationerror_tupler  r2   r4   r  r7   r8   r  error_locationr   s                rC   rM  rM  ,  s    F@B# = =ITF	4Ax!Y,,,,,v'v6N,00@@E}!)T67IX^___e$$$Kw'''' ivw	T[\\\EMM%   'v6N7<$^44MrE   )r   r0   r   r&   r>   r0   )NN)r"  r  r/   r&   r2   r3   rT   rU   r   r   r  r  r  r  r>   r   )r/  r0  r>   r  )K
__future__r   os.pathr   r  r  collectionsr   collections.abcr   typingr   r   r   r	   r
   r   typing_extensionsr   r   rM   mypyr   rm   mypy.error_formatterr   mypy.errorcodesr   r   r   r   r   mypy.optionsr   
mypy.scoper   	mypy.utilr   r   mypy.versionr   r  r   ANNOTATION_UNCHECKEDrn   r   rJ   r   
ASSIGNMENTARG_TYPERETURN_VALUEATTR_DEFINEDNAME_DEFINEDOVERRIDEr   r   r   LITERAL_REQTYPE_ABSTRACTr    r"   tupler0   r3   r:   rN   rP   rU   r  r,  r   r  r  _ErrorLocationrM  rL   rE   rC   <module>r     s   " " " " " " "  



     # # # # # # $ $ $ $ $ $ G G G G G G G G G G G G G G G G > > > > > > > > $ $ $ $ $ $ / / / / / / a a a a a a a a a a a a a a                   = = = = = = = = 4 4 4 4 4 4GCLL  4e6FG G G G G 
J		N				N     XWW  W W W WF F F F F  %0%*e>QSXS]^  ^ ^ ^ ^c! c! c! c! c! c! c! c!P SM3S#sCx	7JJ
    
= = = = = = = =@} } } } } } } }@7 7 7 7 79 7 7 76     ! N N N N Nb# # # # # # # #( sC}%     rE   