
    *eJv                       U d Z ddlmZ ddlZddlZddlZddlZddl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mZmZ ddlmZ 	 ddlZddlZdZn# e$ r dZY nw xY w ed	          Ze	j        d
k    r" e ej         d          dz            Z!de"d<   n< ej#        dd          5 Z$ ee$j%        dz            Z!ddd           n# 1 swxY w Y    ej&        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<    e-d          Z.de"d<   ddd#Z/dd$Z0dd'Z1dd,Z2dd.Z3dd1Z4dd5Z5dd7Z6 G d8 d9e7          Z8dd;Z9dd@Z:ddFZ;ddHZ<dIZ=de"dJ<   dKZ>de"dL<   dMZ?de"dN<   dOZ@de"dP<   dQZAde"dR<   ddZZBdd\ZC G d] d^          ZDdd`ZEddeZFi ZGdfe"dg<   ddkZH	 dddrZIdduZJdddwZKddxZLdd{ZMdd}ZNddZOddZPddZQdddZRddZSddZTddZU G d d          ZVddZWddZXddZYe
jZ        Z[ddZ\ddZ]ddZ^dS )z3Utility functions with no non-trivial dependencies.    )annotationsN)	resources)IOCallable	ContainerFinalIterableSequenceSizedTypeVar)LiteralTFT)   	   mypytypeshedr   TYPESHED_DIRzpy.typeds=   ([ \t\v]*#.*(\r\n?|\n))??[ \t\v]*#.*coding[:=][ \t]*([-\w.]+)ENCODING_RE   DEFAULT_SOURCE_OFFSETP   DEFAULT_COLUMNS   MINIMUM_WIDTH
   MINIMUM_WINDOWS_MAJOR_VT100iZ)  MINIMUM_WINDOWS_BUILD_VT100)__init____new____call____init_subclass____class_getitem__SPECIAL_DUNDERSnamestrexclude_specialboolreturnc                p    |r| t           v rdS |                     d          o|                     d          S )zReturns whether name is a dunder name.

    Args:
        exclude_special: Whether to return False for a couple special dunder methods.

    F__)r#   
startswithendswith)r$   r&   s     )lib/python3.11/site-packages/mypy/util.py	is_dunderr.   ;   s>      4?22u??4  8T]]4%8%88    c                v    t          |            o)|                     d          o|                     d          S N_)r.   r+   r,   r$   s    r-   	is_sunderr4   G   s3    N4??3#7#7NDMM#<N<NNr/   mod_name	list[str]c                ~    | g}d| v r5|                      dd          d         } |                    |            d| v 5|S )zReturn the module and all parent module names.

    So, if `mod_name` is 'a.b.c', this function will return
    ['a.b.c', 'a.b', and 'a'].
    .   r   )rsplitappend)r5   outs     r-   split_module_namesr=   K   sP     *C
//??3**1-

8 // Jr/   modulesIterable[str]target
str | Nonec                :    t          | |          }|d S |d         S Nr   )split_target)r>   r@   results      r-   module_prefixrF   X   s%    '6**F~t!9r/   tuple[str, str] | Nonec                    g }	 || v r|d                     |          fS |                    dd          }t          |          dk    rd S |d         }|                    d|d                    k)NTr8   r9   r   )joinr:   leninsert)r>   r@   	remaining
componentss       r-   rD   rD   _   s    I+W388I....]]3**
z??a4AJqM***+r/   objobjectc                    | dS t          t          |                     }|                    d          d                             d          S )zReturn the last component of the type name of an object.

    If obj is None, return 'nil'. For example, if obj is 1, return 'int'.
    Nnilr8   z'>)r%   typesplitrstrip)rN   ts     r-   
short_typerW   k   sB    
 {uDIIA773<<""4(((r/   textbytestuple[str, int]c                
   t                               |           }|rb|                    d          rdnd}|                    d                              d          }|                    d          s|dk    rd}||fS d}|d	fS )
z*PEP-263 for detecting Python file encodingr9      r   ascii)ziso-latin-1-zlatin-1-ziso-latin-1zlatin-1utf8rR   )r   matchgroupdecoder+   )rX   rE   lineencodingdefault_encodings        r-   find_python_encodingre   v   s    t$$F 	$LLOO*qq<<??))'22;<< 	!M@Y@Y H~!##r/   bc                0    t          |           dd         S )a2  Converts bytes into some human-readable representation. Unprintable
    bytes such as the nul byte are escaped. For example:

        >>> b = bytes([102, 111, 111, 10, 0])
        >>> s = bytes_to_human_readable_repr(b)
        >>> print(s)
        foo
 
        >>> print(repr(s))
        'foo\n\x00'
    r\   rR   )repr)rf   s    r-   bytes_to_human_readable_reprri      s     771R4=r/   c                      e Zd ZdZdS )DecodeErrorzException raised when a file cannot be decoded due to an unknown encoding type.

    Essentially a wrapper for the LookupError raised by `bytearray.decode`
    N)__name__
__module____qualname____doc__ r/   r-   rk   rk      s           r/   rk   sourcec                    |                      d          rd}| dd         } nt          |           \  }}	 |                     |          }n/# t          $ r"}t	          t          |                    |d}~ww xY w|S )zmRead the Python file with while obeying PEP-263 encoding detection.

    Returns the source as a string.
    s   ﻿r^   r   N)r+   re   ra   LookupErrorrk   r%   )rq   rc   r2   source_text	lookuperrs        r-   decode_python_encodingrv      s     )) 3 +622!9mmH-- 9 9 9#i..))y89s   A 
A8A33A8pathreadCallable[[str], bytes]list[str] | Nonec                    	  ||           }	 t          |                                          }n# t          $ r Y dS w xY w|S # t          $ r Y dS w xY w)zaTry reading a Python file as list of source lines.

    Return None if something goes wrong.
    N)rv   
splitlinesrk   OSError)rw   rx   rq   source_liness       r-   read_py_filer      s    
	d	1&99DDFFLL 	 	 	44	    tts   A !0 
>>
AArb   max_lenintcol	min_widthc                L   |d|z  dz   k     rd|z  dz   }t          |           |k    r| dfS ||z   |k     r| d|         dz   dfS |t          |           |z
  dz
  k     r&||z
  |z   dz   }d| |||z   dz            z   dz   |dz
  fS d| | d         z   t          |           |z
  dz
  fS )a  Trim a line of source code to fit into max_len.

    Show 'min_width' characters on each side of 'col' (an error location). If either
    start or end is trimmed, this is indicated by adding '...' there.
    A typical result looks like this:
        ...some_variable = function_to_call(one_arg, other_arg) or...

    Return the trimmed string and the column offset to to adjust error location.
    r\   r9   r   N...r   rJ   )rb   r   r   r   offsets        r-   trim_source_liner      s     Y"""i-!# 4yyGQw Y  HWH~%q(( SYY"Q&&&w*Q.tFS9_q%8899EA6A:MM 4		?"CII$7!$;;;r/   list[tuple[int, str]]c                    d}|| vrg S |                      d          }g }t          |          D ]I\  }}|                    |          r/|                    |dz   |t	          |          d          f           J|S )Nz# mypy: 
r9   )rT   	enumerater+   r;   rJ   )rq   PREFIXlinesresultsirb   s         r-   get_mypy_commentsr      s    FV	LLEGU## 9 94??6"" 	9NNAE4F#67888Nr/   z<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="{errors}" failures="{failures}" name="mypy" skips="0" tests="{tests}" time="{time:.3f}">
JUNIT_HEADER_TEMPLATEz  <testcase classname="mypy" file="{filename}" line="1" name="{name}" time="{time:.3f}">
    <failure message="mypy produced messages">{text}</failure>
  </testcase>
JUNIT_TESTCASE_FAIL_TEMPLATEz  <testcase classname="mypy" file="mypy" line="1" name="mypy-py{ver}-{platform}" time="{time:.3f}">
    <error message="mypy produced errors">{text}</error>
  </testcase>
JUNIT_ERROR_TEMPLATEzr  <testcase classname="mypy" file="mypy" line="1" name="mypy-py{ver}-{platform}" time="{time:.3f}">
  </testcase>
JUNIT_TESTCASE_PASS_TEMPLATEz</testsuite>
JUNIT_FOOTERdtfloatseriousmessages_by_filedict[str | None, list[str]]versionplatformc                d   |rd}t          |          }nt          |          }d}t                              ||| t          |          pd          }|s!|t                              | ||          z  }n|                                D ]\  }}	|K|t
                              d                    |	          || d                    |||                    z  }R|t
                              d                    |	          d	| d
                    ||                    z  }|t          z  }|S )Nr   r9   )errorsfailurestimetests)r   verr   r   z"mypy-py{ver}-{platform} {filename})r   r   filename)rX   r   r   r$   r   zmypy-py{ver}-{platform})r   r   )rJ   r   formatr   itemsr   rI   r   )
r   r   r   r   r   r   r   xmlr   messagess
             r-   _generate_junit_contentsr     sw     %&&'((

&
&"##(q '  C  +22RZ2[[["2"8"8":": 	 	Hh#3::8,,%=DD#h E  	 ;    3::8,,#299gPX9YY	 ;    <CJr/   Nonec                   t          | ||||          }t          j                            t          j                            |                    }t          j                            |          st          j        |           t          |d          5 }|                    |	                    d                     d d d            d S # 1 swxY w Y   d S )Nwbutf-8)
r   osrw   dirnameabspathisdirmakedirsopenwriteencode)	r   r   r   rw   r   r   r   xml_dirsfs	            r-   write_junit_xmlr   3  s     #2w0@'8
T
TC wrwt4455H7=="" 
H	dD		 %Q	

7##$$$% % % % % % % % % % % % % % % % % %s   )C		CCc                  "    e Zd ZdZd
dZddZd	S )IdMapperzGenerate integer ids for objects.

    Unlike id(), these start from 0 and increment by 1, and ids won't
    get reused across the life-time of IdMapper.

    Assume objects don't redefine __eq__ or __hash__.
    r(   r   c                "    i | _         d| _        d S rC   id_mapnext_idselfs    r-   r   zIdMapper.__init__O  s    )+r/   orO   r   c                l    || j         vr| j        | j         |<   | xj        dz  c_        | j         |         S )Nr9   r   )r   r   s     r-   idzIdMapper.idS  s8    DK!\DKNLLALL{1~r/   N)r(   r   )r   rO   r(   r   )rl   rm   rn   ro   r   r   rp   r/   r-   r   r   F  sF                 r/   r   fullnamec                :    |                      dd          d         S )zBDrop the final component of a qualified name (e.g. ('x.y' -> 'x').r8   r9   r   )r:   )r   s    r-   
get_prefixr   Z  s    ??3""1%%r/   
cur_mod_idrelativeis_cur_package_init_filetuple[str, bool]c                    |dk    r|dfS |                      d          }|}|r|dz  }t          |          |k    }|dk    rd                    |d |                    } | |rd|z   ndz   |fS )Nr   Tr8   r9    )rT   rJ   rI   )r   r   r@   r   partsreloks          r-   correct_relative_importr   _  s     1}}t|S!!E
C q	Us	B
axxXXeEcTEl++
69#,,r:B>>r/   z$Final[dict[type[object], list[str]]]fields_cacheclstype[object]Sequence[str]c                    dd l | t          vr-                    | fd          }d |D             t          | <   t          |          S )Nr   c                X                         |           p                    |           S N)isgetsetdescriptorismemberdescriptor)r   inspects    r-   <lambda>z'get_class_descriptors.<locals>.<lambda>x  s)    755a88YG<V<VWX<Y<Y r/   c                0    g | ]\  }}|d k    |dk    |S )__weakref____dict__rp   ).0xys      r-   
<listcomp>z)get_class_descriptors.<locals>.<listcomp>z  s,    ]]]41aa=6H6HQR\__Q___r/   )r   r   
getmembers)r   membersr   s     @r-   get_class_descriptorsr   q  sc    NNN ,$$YYYY
 
 ^]7]]]Sr/   rp   newold	copy_dict
skip_slotstuple[str, ...]c           	     p   t          |d          r(|rt          |j                  | _        n|j        | _        t          |j                  D ]h}||v r	 t          ||          r t          | |t          ||                     n t          | |          rt          | |           Y# t          $ r Y ew xY wdS )a   Copy state of old node to the new node.

    This handles cases where there is __dict__ and/or attribute descriptors
    (either from slots or because the type is defined in a C extension module).

    Assume that both objects have the same __class__.
    r   N)	hasattrdictr   r   	__class__setattrgetattrdelattrAttributeError)r   r   r   r   attrs        r-   replace_object_stater   ~  s     sJ ( 	(--CLL<CL%cm44  :
	sD!! #T73#5#56666d## #T"""
  	 	 	D	 s   AB&&
B32B3path1path2c                \    t          j        |          t          j        |           j        v S )z8Given two paths, return if path1 is a sub-path of path2.)pathlibPathparents)r   r   s     r-   is_sub_pathr     s$    <',u"5"5"===r/   statusc                    t           j                                         t           j                                         t	          j        |            dS )zKill the current process without fully cleaning up.

    This can be quite a bit faster than a normal exit() since objects are not freed.
    N)sysstdoutflushstderrr   _exit)r   s    r-   	hard_exitr    sB    
 JJHVr/   c                ,    |                      d          S )z+Remove internal suffixes from a short name.')rU   r3   s    r-   unmangler    s    ;;sr/   existingContainer[str]c                    | dz   }||vr|S d}|t          |          z   |v r|dz  }|t          |          z   |v |t          |          z   S )zGet a simple redefinition name not present among existing.

    For example, for name 'foo' we try 'foo-redefinition', 'foo-redefinition2',
    'foo-redefinition3', etc. until we find one that is not in existing.
    z-redefinitionr\   r9   )r%   )r$   r  r_namer   s       r-   get_unique_redefinition_namer    sh     O#FX	A
3q66/X
%
%	Q 3q66/X
%
%CFF?r/   programc                    t           j        dd         dk     r*t          j        d                    |                      dS dS )zAReport issues with the Python used to run mypy, dmypy, or stubgenNr\   )r      zXRunning {name} with Python 3.7 or lower is not supported; please upgrade to 3.8 or newerr3   )r   version_infoexitr   )r  s    r-   check_python_versionr    sU     f$$--3VV-A-A	
 	
 	
 	
 	
 %$r/   r   tuple[int, int, int]c                    d | D             }d |D             }d | D             }t          |          t          |          t          |          fS )zDCount total number of errors, notes and error_files in message list.c                    g | ]}d |v |	S ): error:rp   r   es     r-   r   zcount_stats.<locals>.<listcomp>  s    555AZ1__a___r/   c                D    h | ]}|                     d           d         S ):r   )rT   r  s     r-   	<setcomp>zcount_stats.<locals>.<setcomp>  s&    333q1773<<?333r/   c                    g | ]}d |v |	S ): note:rp   r  s     r-   r   zcount_stats.<locals>.<listcomp>  s    3331INNQNNNr/   r   )r   r   error_filesnotess       r-   count_statsr    s\    55555F33F333K33333Ev;;E

C$4$444r/   msgc                    d}g }d}| D ]0}|dk    r|r|                     |           d}"|dk    r| }||z  }1|                     |           |S )z=Split line of text into words (but not within quoted groups).r   T ")r;   )r   	next_wordresallow_breakcs        r-   split_wordsr(    sy    ICK  888JJy!!!I88)/KQ		JJyJr/   c                     t          t          j        dd                    pt          j                    j        pt          S )zIGet current terminal width if possible, otherwise return the default one.MYPY_FORCE_TERMINAL_WIDTH0)r   r   getenvshutilget_terminal_sizecolumnsr   rp   r/   r-   get_terminal_widthr0    s=     	BI137788 	#%%-	r/   first_offset
num_indentc                   t          |           }|                    d          }g }|ri|                    d          }|r||z
  n||z
  }t          |          t          |          z   dz   |k    r	|d|z   z  }n|                    |           |}|i|                    |           dd|z  z   }	|	                    |          S )a  Wrap a long error message into few lines.

    Breaks will only happen between words, and never inside a quoted group
    (to avoid breaking types such as "Union[int, str]"). The 'first_offset' is
    the width before the start of first line.

    Pad every next line with 'num_indent' spaces. Every line will be at most 'max_len'
    characters, except if it is a single word or quoted group.

    For example:
               first_offset
        ------------------------
        path/to/file: error: 58: Some very long error message
            that needs to be split in separate lines.
            "Long[Type, Names]" are never split.
        ^^^^--------------------------------------------------
        num_indent           max_len
    r   r9   r"  r   )r(  poprJ   r;   rI   )
r   r   r1  r2  words	next_liner   r$  max_line_lenpaddings
             r-   	soft_wrapr9    s    & E		!IE
 "IIaLL	/4Pw++'L:Py>>C	NN*Q.,>>y(IILL###!I  " 
LLS:%%G<<r/   datac                N    t          j        |                                           S )zCompute a hash digest of some data.

    We use a cryptographic hash because we want a low probability of
    accidental collision, but we don't really care about any of the
    cryptographic properties.
    )hashlibsha256	hexdigest)r:  s    r-   hash_digestr?    s      >$))+++r/   cupc                   t           j        dk    r
J d            d                    | dd                                         dg          }t	          j        |                    d          d	d
                                          }|S )z.Reproduce a gray color in ANSI escape sequencewin32Fz"curses is not available on Windowsr   NrR   mr   r9   r   )r   r   rI   ra   cursestparmr   )r@  	set_colorgrays      r-   parse_gray_colorrH    sx    
|w:::::SbS**C011I<	((111a88??AADKr/   c                     t          j        dt          j        dd                    } 	 t          t          |                     S # t          $ r t          |           cY S w xY w)NMYPY_FORCE_COLORFORCE_COLORr+  )r   r,  r'   r   
ValueError)env_vars    r-   should_force_colorrN  '  sf    i*BImS,I,IJJGCLL!!!   G}}s   A A"!A"c                      e Zd ZdZd,d	Zd-d
Zd-dZd-dZ	 	 	 d.d/dZ	 d0d1dZ	d2dZ
d3dZd4d!Zd5d6d&Zdd"d'd7d+ZdS )8FancyFormatterzcApply color and bold font to terminal output.

    This currently only works on Linux and Mac.
    f_outIO[str]f_errhide_error_codesr'   r(   r   c                   || _         t          j        dvr	d| _        d S t	                      s1|                                r|                                s	d| _        d S t          j        dk    r|                                  | _        nEt          j        dk    r|                                  | _        n|                                  | _        | j        s#| j	        | j
        | j        | j        dd| _        d S d S )N)linuxdarwinrB  
emscriptenTrB  rX  r   )redgreenblueyellownone)rT  r   r   
dummy_termrN  isattyinitialize_win_colorsinitialize_vt100_colorsinitialize_unix_colorsREDGREENBLUEYELLOWcolors)r   rQ  rS  rT  s       r-   r   zFancyFormatter.__init__5  s     0<III"DOF!## 	U\\^^ 	5<<>> 	"DOF<7"""&"<"<">">>DOO\\))"&">">"@"@@DOO"&"="="?"??DO 	x	+ DKKK	 	r/   c                    t           j        dv sJ d| _        d| _        d| _        d| _        d| _        d| _        d| _        d	| _	        d
S )SReturn True if initialization was successful and we can use colors, False otherwise)rB  rX  z[1mz[4mz[94mz[92mz[91mz[93mz[0mz[2mT)
r   r   BOLDUNDERre  rd  rc  rf  NORMALDIMr   s    r-   ra  z&FancyFormatter.initialize_vt100_colorsM  sU     |66666	
	
 tr/   c                n   t           j        dk    sJ t           j        dk    rt          j                    }|j        t          k     s|j        t          k     rdS ddl}|j        j	        }d}d}d}d}|
                    |                    |          ||z  |z             |                                  d	S dS )
ri  rB  Fr   Nr9   r\   r   iT)r   r   getwindowsversionmajorr   buildr   ctypeswindllkernel32SetConsoleModeGetStdHandlera  )r   winverrr  rt  ENABLE_PROCESSED_OUTPUTENABLE_WRAP_AT_EOL_OUTPUT"ENABLE_VIRTUAL_TERMINAL_PROCESSINGSTD_OUTPUT_HANDLEs           r-   r`  z$FancyFormatter.initialize_win_colors[  s    
 |w&&&&<7""*,,F:::<"===uMMM}-H&)#(+%14. ###%%&788'+,45   ((***4ur/   c                   t           j        dk    st          sdS 	 	 t           j                                        }t          j        |           nd# t          j        $ rR t          dd          5 }t          j        |                                           ddd           n# 1 swxY w Y   Y nw xY wn# t
          j
        $ r Y dS w xY wt          j        d          }t          j        d          }t          j        d	          }t          j        d
          }t          j        d          }|r|r|r|r|sdS |                                | _        |                                | _        |                                | _        t!          |          | _        t          j        |t
          j                                                  | _        t          j        |t
          j                                                  | _        t          j        |t
          j                                                  | _        t          j        |t
          j                                                  | _        dS )ri  rB  F)fdz	/dev/nullrbNboldsmulsetafr@  sgr0T)r   r   CURSES_ENABLEDr   filenorD  	setuptermioUnsupportedOperationr   errortigetstrra   rl  rj  rk  rH  rm  rE  
COLOR_BLUEre  COLOR_GREENrd  	COLOR_REDrc  COLOR_YELLOWrf  )r   r}  r   r  underrF  set_eseqnormals           r-   rb  z%FancyFormatter.initialize_unix_colorsy  sU   <7""."5	(Z&&((
  B'''''	 * 4 4 4+t,, 4$

33334 4 4 4 4 4 4 4 4 4 4 4 4 4 44
 | 	 	 	55	 v&&''OG,,	?5))(( 	 	9 	 	f 	5mmooKKMM	\\^^
#H--LF,=>>EEGG	\)V-?@@GGII
<	6+;<<CCEEl9f.ABBIIKKtsR   A B5 B1/(B#B1#B'	'B1*B'	+B1.B5 0B11B5 5CCFrX   r%   color1Literal['red', 'green', 'blue', 'yellow', 'none']r  	underlinedimc                    | j         r|S |r| j        }nd}|r
|| j        z  }|r
|| j        z  }|| j        |         z   |z   | j        z   S )z2Apply simple color and style (underlined or bold).r   )r^  rj  rk  rm  rg  rl  )r   rX   r  r  r  r  starts          r-   stylezFancyFormatter.style  so     ? 	K 	IEEE 	 TZE 	TXEt{5))D04;>>r/   Nr   r6   fixed_terminal_width
int | Nonec           	        |pt                      }|                                }t          |          D ]\  }}d|v rT|                    dd          \  }}t	          ||t          |          t          d          z             }|dz   |z   ||<   |                    dt          z            rd|vr|t          d	         }||dz            }	|	                    d          }
|
t          z
  }d
|	vrd}n |	|
|		                    d
          dz            }|t          z
  dz
  }t          |||t                    \  }}dt          z  |z   ||<   dt          |z   |z
  z  |z   }t          |          t          ||                   k    r6t          |          dk    r#|d	t          ||                   dz
           dz   }|||dz   <   |S )zHImprove readability by wrapping error messages and trimming source code.r  error:r9   maxsplitzerror: )r1  r"  ^N~   r   r   )r0  copyr   rT   r9  rJ   r+   r   indexrindexr   r   )r   r   r  widthnew_messagesr   r  locr   marker_linemarker_columncolumnmarkerr   source_liner   new_marker_lines                    r-   fit_in_terminalzFancyFormatter.fit_in_terminal  s    %<(:(<(<}}!(++ 	6 	6HAuU"" ;;x!;<<SUSC	NN9RSSS"%.3"6Q&; ;<< 6EAQAQ 3445&q1uo + 1 1# 6 6&)>>k)) FF )9K9KC9P9PST9T)TUF  "77!;&6ugv}&]&]#V"%(="="KQ"%)>)G&)P"QTZ"Z''#l1o*>*>>>3v;;QR??&56PLO8L8Lq8P6P&QTY&YO&5QU#r/   r  c                   d|v r|                     dd          \  }}| j        r1||                     ddd          z   |                     |          z   S |                    d          }|d	k    r||d
         }|d
|         }nd}||                     ddd          z   |                     |          z   |                     |d          z   S d|v r^|                     dd          \  }}|                     |                     |                    }||                     dd          z   |z   S |                    dt          z            r2d|vr|                     |dd          S |                     |d          S |S )zBColorize an output line by highlighting the status and error code.r  r  r9   r  rY  Tr  [rR   Nr   r\  r  znote:r[  r"  r  r]  )r  )rT   rT  r  highlight_quote_groupsrfindunderline_linkr+   r   )r   r  r  r   codeposcode	formatteds          r-   colorizezFancyFormatter.colorize  s   {{8a{88HC$ $**Xu4*@@@4C^C^_bCcCcc iinnG"}}788}(7(m**Xu4*889--c223 **T8,,- %{{7Q{77HC33D4G4G4L4LMMIGV444y@@c$99:: 	%zz%Tz:::::eU+++Lr/   r   c                   |                     d          dz  r|S |                    d          }d}t          |          D ]I\  }}|dz  dk    r||                     |d          z  }(||                     d|z   dz   dd          z  }J|S )zMake groups quoted with double quotes bold (including quotes).

        This is used to highlight types, attribute names etc.
        r#  r\   r   r   r]  Tr  )countrT   r   r  )r   r   r   r<   r   parts         r-   r  z%FancyFormatter.highlight_quote_groups  s    
 99S>>A 	J		# '' 	G 	GGAt1uzztzz$///tzz#*s"2FzFFF
r/   notec                    t          j        d|          }|s|S |                                }|                                }|d|         |                     |||         dd          z   ||d         z   S )zuUnderline a link in a note message (if any).

        This assumes there is at most one link in the message.
        zhttps?://\S*Nr]  T)r  )researchr  endr  )r   r  r_   r  r  s        r-   r  zFancyFormatter.underline_link	  s{    
 	/400 	KiikkFUF|djjeCi&DjQQQTXY\Y]Y]T^^^r/   T	n_sourcesr   	use_colorc                d    d| dt          |           }|s|S |                     |dd          S )zFormat short summary in case of success.

        n_sources is total number of files passed directly on command line,
        i.e. excluding stubs and followed imports.
        zSuccess: no issues found in  source filerZ  Tr  plural_sr  )r   r  r  r   s       r-   format_successzFancyFormatter.format_success  sG     ZYYYHYDWDWYY 	Jzz#wTz222r/   )blockersr  n_errorsn_filesr  c          
         d| dt          |           d| dt          |           }|r|dz  }n|d| dt          |           dz  }|s|S |                     |d	d
          S )z)Format a short summary in case of errors.zFound z errorz in z filez$ (errors prevented further checking)z
 (checked r  )rY  Tr  r  )r   r  r  r  r  r  r   s          r-   format_errorzFancyFormatter.format_error   s     ax``x'9'9``w``XV]M^M^`` 	N99CCM	MMx	7J7JMMMMC 	Jzz#u4z000r/   )rQ  rR  rS  rR  rT  r'   r(   r   r(   r'   )FFF)rX   r%   r  r  r  r'   r  r'   r  r'   r(   r%   r   )r   r6   r  r  r(   r6   )r  r%   r(   r%   )r   r%   r(   r%   )r  r%   r(   r%   )T)r  r   r  r'   r(   r%   )r  r   r  r   r  r   r  r'   r  r'   r(   r%   )rl   rm   rn   ro   r   ra  r`  rb  r  r  r  r  r  r  r  rp   r/   r-   rP  rP  /  s4        
   0      <# # # #R ? ? ? ? ?, GK# # # # #J   @   "
_ 
_ 
_ 
_	3 	3 	3 	3 	3" 1 1 1 1 1 1 1 1r/   rP  typeshed_dirfilec                    | | nt           } 	 t          j                            | t          j                            |          f          | k    S # t
          $ r Y dS w xY w)NF)r   r   rw   
commonpathr   rL  )r  r  s     r-   is_typeshed_filer  4  se    #/#;<<Lw!!<1F1F"GHHLXX   uus   AA 
AAc                    |                      d          sdS t          d t          j                            t          j                            |                     D                       S )Nz.pyiFc              3  @   K   | ]}|                     d           V  dS )z-stubsN)r,   )r   	components     r-   	<genexpr>z'is_stub_package_file.<locals>.<genexpr>@  s0      bb	y!!(++bbbbbbr/   )r,   anyr   rw   rT   r   )r  s    r-   is_stub_package_filer  <  sU    ==   ubbRW]]27??[_K`K`=a=abbbbbbr/   c                    | d uo| dk    S r1   rp   r3   s    r-   unnamed_functionr  C  s    t++r/   t0c                N    t          t          j                    | z
  dz            S )Ni  )r   r   perf_counter_ns)r  s    r-   time_spent_usr  J  s#    $&&+t3444r/   sint | Sizedc                b    t          | t                    r| nt          |           }|dk    rdS dS )Nr9   r  r   )
isinstancer   rJ   )r  r  s     r-   r  r  N  s3    As##/AAQEzzsrr/   docstrc                    d                     t          j        dt          |                               }|                    d          r,d|dd         vr|d         dk    rd|dd          dS d	| d	S d
| d
S )zKReturns docstring correctly encapsulated in a single or double quoted form.r   z(?<=[^\\])\\nr  r#  r9   rR   z"""z''z"")rI   r  rT   rh   r+   )r  docstr_reprs     r-   quote_docstringr  V  s     ))BH%5tF||DDEEKc"" $ k!B$'''KOs,B,B/QrT*////#K#####K####r/   )F)r$   r%   r&   r'   r(   r'   )r$   r%   r(   r'   )r5   r%   r(   r6   )r>   r?   r@   r%   r(   rA   )r>   r?   r@   r%   r(   rG   )rN   rO   r(   r%   )rX   rY   r(   rZ   )rf   rY   r(   r%   )rq   rY   r(   r%   )rw   r%   rx   ry   r(   rz   )
rb   r%   r   r   r   r   r   r   r(   rZ   )rq   r%   r(   r   )r   r   r   r'   r   r   r   r%   r   r%   r(   r%   )r   r   r   r'   r   r   rw   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   )Frp   )
r   rO   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   r6   r(   r  )r   r%   r(   r6   )r(   r   )
r   r%   r   r   r1  r   r2  r   r(   r%   )r:  rY   r(   r%   )r@  rY   r(   r%   r  )r  rA   r  r%   r(   r'   )r  r%   r(   r'   )r$   rA   r(   r'   )r  r   r(   r   )r  r  r(   r%   )r  r%   r(   r%   )_ro   
__future__r   r<  r  r   r   r  r-  r   r   	importlibr   importlib_resourcestypingr   r   r   r   r	   r
   r   r   typing_extensionsr   rD  _cursesr  ImportErrorr   r  r%   filesr   __annotations__rw   	_resourceparentcompiler   r   r   r   r   r   	frozensetr#   r.   r4   r=   rF   rD   rW   re   ri   	Exceptionrk   rv   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r(  r0  r9  r?  rH  rN  rP  r  r  r  r  time_refr  r  r  rp   r/   r-   <module>r     s   9 9 9 " " " " " "  				 				  				  



  6 6 6 6 6 6 U U U U U U U U U U U U U U U U U U U U % % % % % %MMMNNNNN   NNN GCLLv#717??*LMMLMMMMM	!		!
 
 : 
s9+j899	: : : : : : : : : : : : : : :  RZ abb b b b b                    &(  ' ' ' '%*  * * * *"Q     
	9 	9 	9 	9 	9O O O O
 
 
 
   	+ 	+ 	+ 	+) ) ) )$ $ $ $       )      (   "< < < <@         '     
     
'         - - - -`% % % %&       (& & & &
? ? ? ? 68 7 7 7 7
 
 
 
 VX    @> > > >
       
    
 
 
 
5 5 5 5   "   ! ! ! ! !H	, 	, 	, 	,      B1 B1 B1 B1 B1 B1 B1 B1J   c c c c, , , , 5 5 5 5   $ $ $ $ $ $s$   
A A A ,CCC