
    X-Phc                       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mZmZmZ ddlmZ ddlmZmZmZmZmZmZ ded<   	 ddlZn# e$ r dZY nw xY w	 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! ej"        d          dz            Z#ded<    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$Z.dd'Z/dd,Z0dd.Z1dd1Z2dd5Z3dd7Z4 G d8 d9e5          Z6dd;Z7dd@Z8ddFZ9ddHZ:dIZ;dedJ<   dKZ<dedL<   dMZ=dedN<   dOZ>dedP<   dQZ?dedR<   ddZZ@dd\ZA G d] d^          ZBdd`ZCddeZDi ZEdfedg<   ddkZF	 dddrZGddtZHe	jI        duk    se	jI        dvk    rddwZJnddzZJddd|ZKdd}ZLddZMddZNddZOddZPddZQdddZRddZSddZTddZU G d d          ZVddZWddZXddZYddZZe
j[        Z\ddZ]ddZ^ddZ_dddZ`ddZadS )z3Utility functions with no non-trivial dependencies.    )annotationsN)	ContainerIterableSequenceSized)	resources)IOAnyCallableFinalLiteralTypeVarr
   orjsonTFTmypytypeshedr   TYPESHED_DIRs=   ([ \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     I/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/util.py	is_dunderr.   8   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   D   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=   H   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   U   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   h   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         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_encodingrf   s   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)rg   s    r-   bytes_to_human_readable_reprrj      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-   rl   rl      s           r/   rl   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+   rf   rb   LookupErrorrl   r%   )rr   rd   r2   source_text	lookuperrs        r-   decode_python_encodingrw      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)rw   
splitlinesrl   OSError)rx   ry   rr   source_liness       r-   read_py_filer      s    
	d	1&99DDFFLL 	 	 	44	    tts   A !0 
>>
AArc   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 adjust error location.
    r\   r9   r   N...r]   rJ   )rc   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   )rr   PREFIXlinesresultsirc   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                v   ddl m} |rd}t          |          }nt          |          }d}t                              ||| t          |          pd          }|s!|t
                              | ||          z  }n|                                D ]\  }	}
|	T|t                               |d                    |
                    |	| d                    |||	          	          z  }[|t                               |d                    |
                    d
| d| d| 	          z  }|t          z  }|S )Nr   )escaper9   )errorsfailurestimetests)r   verr   r   z"mypy-py{ver}-{platform} {filename})r   r   filename)rX   r   r   r$   r   zmypy-py-)
xml.sax.saxutilsr   rJ   r   formatr   itemsr   rI   r   )r   r   r   r   r   r   r   r   xmlr   messagess              r-   _generate_junit_contentsr      s    (''''' %&&'((

&
&"##(q '  C  +22RZ2[[["2"8"8":": 	 	Hh#3::		( 3 344%=DD#h E  	 ;    3::		( 3 344#7777X77	 ;    <CJr/   Nonec                r   t          | ||||          }t          j                            t          j                            |                    }t          j        |d           t          |d          5 }|                    |                    d                     d d d            d S # 1 swxY w Y   d S )NT)exist_okwbutf-8)	r   osrx   dirnameabspathmakedirsopenwriteencode)	r   r   r   rx   r   r   r   xml_dirsfs	            r-   write_junit_xmlr   2  s     #2w0@'8
T
TC wrwt4455HK4((((	dD		 %Q	

7##$$$% % % % % % % % % % % % % % % % % %s   6)B,,B03B0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__M  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.idQ  s8    DK!\DKNLLALL{1~r/   N)r(   r   )r   rO   r(   r   )rm   rn   ro   rp   r   r   rq   r/   r-   r   r   D  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   X  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>v  s)    755a88YG<V<VWX<Y<Y r/   c                0    g | ]\  }}|d k    |dk    |S )__weakref____dict__rq   ).0xys      r-   
<listcomp>z)get_class_descriptors.<locals>.<listcomp>x  s,    ]]]41aa=6H6HQR\__Q___r/   )r   r   
getmembers)r   membersr   s     @r-   get_class_descriptorsr   o  sc    NNN ,$$YYYY
 
 ^]7]]]Sr/   rq   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dirc                    |                     t          j                  s|t          j        z  }|                     |          S )ay  Given two paths, return if path is a sub-path of dir.

    Moral equivalent of: Path(dir) in Path(path).parents

    Similar to the pathlib version:
    - Treats paths case-sensitively
    - Does not fully handle unnormalised paths (e.g. paths with "..")
    - Does not handle a mix of absolute and relative paths
    Unlike the pathlib version:
    - Fast
    - On Windows, assumes input has been slash normalised
    - Handles even fewer unnormalised paths (e.g. paths with "." and "//")

    As a result, callers should ensure that inputs have had os.path.abspath called on them
    (note that os.path.abspath will normalise)
    )r,   r   sepr+   )rx   r   s     r-   is_sub_path_normabsr     s7    " << rv??3r/   linuxdarwinc                x    |                     d          s| s|S |                     d          r| |z   S | dz   |z   S )N/)r+   r,   )rx   rg   s     r-   os_path_joinr    sM    << 	"D 	"H]]3 	"!8O#:>!r/   apc                B    t           j                            | |          S r   )r   rx   rI   )r  r  s     r-   r  r    s    w||Aq!!!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.8 or lower is not supported; please upgrade to 3.9 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:rq   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:rq   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_wordsr1    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   rq   r/   r-   get_terminal_widthr9    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   )r1  poprJ   r;   rI   )
r)  r   r:  r;  words	next_liner   r-  max_line_lenpaddings
             r-   	soft_wraprB    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sha1	hexdigestrC  s    r-   hash_digestrI  2  s      <'')))r/   cupc                   t           j        dk    s
J d            d                    | dd                                         dg          }t	          j        |                    d          dd	                                          }|S )
z.Reproduce a gray color in ANSI escape sequencewin32z"curses is not available on Windowsr   NrR   mr   r9   r  )r  r   rI   rb   cursestparmr   )rJ  	set_colorgrays      r-   parse_gray_colorrR  <  sx    <7"""$H"""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_COLORr4  )r   r5  r'   r   
ValueError)env_vars    r-   should_force_colorrX  D  sf    i*BImS,I,IJJGCLL!!!   G}}s   A A"!A"c                      e Zd ZdZ	 d-d.dZd/dZd/dZd/dZ	 	 	 d0d1dZ	 d2d3dZ	d4dZ
d5d Zd6d"Zd7d8d'Zdd#d(d9d,ZdS ):FancyFormatterzcApply color and bold font to terminal output.

    This currently only works on Linux and Mac.
    Ff_outIO[str]f_errhide_error_codesr'   hide_successr(   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)r   r   rL  
emscriptenTrL  ra  r   )redgreenblueyellownone)r^  r_  r  r   
dummy_termrX  isattyinitialize_win_colorsinitialize_vt100_colorsinitialize_unix_colorsREDGREENBLUEYELLOWcolors)r   r[  r]  r^  r_  s        r-   r   zFancyFormatter.__init__R  s    !1( <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)rL  ra  z[1mz[4mz[94mz[92mz[91mz[93mz[0mz[2mT)
r  r   BOLDUNDERrn  rm  rl  ro  NORMALDIMr   s    r-   rj  z&FancyFormatter.initialize_vt100_colorsn  sU     |66666	
	
 tr/   c                Z   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 J d
            )rr  rL  Fr   Nr9   r\   r   iTzRunning not on Windows)r  r   getwindowsversionmajorr   buildr   ctypeswindllkernel32SetConsoleModeGetStdHandlerj  )r   winverr{  r}  ENABLE_PROCESSED_OUTPUTENABLE_WRAP_AT_EOL_OUTPUT"ENABLE_VIRTUAL_TERMINAL_PROCESSINGSTD_OUTPUT_HANDLEs           r-   ri  z$FancyFormatter.initialize_win_colors|  s    
 <7""*,,F:::<"===uMMM}-H&)#(+%14. ###%%&788'+,45   ((***4.....r/   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 )rr  rL  F)fdz	/dev/nullrbNboldsmulsetafrJ  sgr0T)r  r   CURSES_ENABLEDr  filenorN  	setuptermioUnsupportedOperationr   errortigetstrrb   ru  rs  rt  rR  rv  rO  
COLOR_BLUErn  COLOR_GREENrm  	COLOR_REDrl  COLOR_YELLOWro  )	r   is_winr  r   r  underrP  set_eseqnormals	            r-   rk  z%FancyFormatter.initialize_unix_colors  s^   ( 	 	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 B7 B31(B%B3%B)	)B3,B)	-B30B7 2B33B7 7C
	C
rX   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   )rg  rs  rt  rv  rp  ru  )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: )r:  r+  ^N~   r]   r   )r9  copyr   rT   rB  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  rb  Tr  [rR   Nr   re  r%  znote:rd  r+  r  rf  )r  )rT   r^  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   rf  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*Nrf  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                v    | j         rdS 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.
        r   zSuccess: no issues found in  source filerc  Tr  )r_  plural_sr  )r   r  r  r)  s       r-   format_successzFancyFormatter.format_success6  sV      	2YY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  )rb  Tr  )r  r  )r   r  r  r  r  r  r)  s          r-   format_errorzFancyFormatter.format_errorD  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/   F)
r[  r\  r]  r\  r^  r'   r_  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%   )rm   rn   ro   rp   r   rj  ri  rk  r  r  r  r  r  r  r  rq   r/   r-   rZ  rZ  L  s@         \a    8   / / / /:$ $ $ $T ? ? ? ? ?, GK# # # # #J   @   "
_ 
_ 
_ 
_3 3 3 3 3( 1 1 1 1 1 1 1 1r/   rZ  typeshed_dirfilec                    | | nt           } 	 t          j                            | t          j                            |          f          | k    S # t
          $ r Y dS w xY w)NF)r   r   rx   
commonpathr   rV  )r  r  s     r-   is_typeshed_filer  X  se    #/#;<<Lw!!<1F1F"GHHLXX   uus   AA 
AAc                   d|vrdS | | nt           } t          j                            | d          }	 t          j                            |t          j                            |          f          |k    S # t          $ r Y dS w xY w)NstdlibF)r   r   rx   rI   r  r   rV  )r  r  
stdlib_dirs      r-   is_stdlib_filer  `  s    tu#/#;<<LlH55Jw!!:rwt/D/D"EFF*TT   uus   AA5 5
BB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>p  s0      bb	y!!(++bbbbbbr/   )r,   anyr   rx   rT   r   )r  s    r-   is_stub_package_filer  l  sU    ==   ubbRW]]27??[_K`K`=a=abbbbbbr/   c                    | d uo| dk    S r1   rq   r3   s    r-   unnamed_functionr  s  s    t++r/   t0c                N    t          t          j                    | z
  dz            S )Ni  )r   r   perf_counter_ns)r  s    r-   time_spent_usr  z  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  ~  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   ri   r+   )r  docstr_reprs     r-   quote_docstringr    s     ))BH%5tF||DDEEKc"" $ k!B$'''KOs,B,B/QrT*////#K#####K####r/   debugc                   t           j|rt           j        t           j        z  }nt           j        }	 t          j        | |          S # t          $ r}t          |          dk    r Y d }~nd }~ww xY w|r*t          j        | dd                              d          S t          j        | dd                              d          S )	N)optionzInteger exceeds 64-bit ranger\   T)indent	sort_keysr   ),r"  )r  
separators)r   OPT_INDENT_2OPT_SORT_KEYSdumps	TypeErrorr%   jsonr   )rN   r  dumps_optionr   s       r-   
json_dumpsr    s     	0!.1EELL "/L	<L9999 	 	 	1vv777 87777	  Vz#a4888??HHH z#*EEELLWUUUs   A 
A/A**A/c                `    t           t          j        |           S t          j        |           S r   )r   loadsr  rH  s    r-   
json_loadsr    s(    |D!!!:dr/   r  )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   )rg   rY   r(   r%   )rr   rY   r(   r%   )rx   r%   ry   rz   r(   r{   )
rc   r%   r   r   r   r   r   r   r(   rZ   )rr   r%   r(   r   )r   r   r   r'   r   r   r   r%   r   r%   r(   r%   )r   r   r   r'   r   r   rx   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   )Frq   )
r   rO   r   rO   r   r'   r   r   r(   r   )rx   r%   r   r%   r(   r'   )rx   r%   rg   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   r:  r   r;  r   r(   r%   )rC  rY   r(   r%   )rJ  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%   )rN   rO   r  r'   r(   rY   )rC  rY   r(   r
   )brp   
__future__r   rE  r  r  r   r  r6  r  r   collections.abcr   r   r   r   	importlibr   importlib_resourcestypingr	   r
   r   r   r   r   __annotations__r   ImportError_cursesrN  r  r   r%   filesr   compiler   r   r   r   r   r   	frozensetr#   r.   r4   r=   rF   rD   rW   rf   rj   	Exceptionrl   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(  r1  r9  rB  rI  rR  rX  rZ  r  r  r  r  r  time_refr  r  r  r  r  rq   r/   r-   <module>r     s   9 9 9 " " " " " "  				  				 				  



  @ @ @ @ @ @ @ @ @ @ @ @ 6 6 6 6 6 6 = = = = = = = = = = = = = = = = MMMM   FFFNNNMMMNN   NNN GCLLc3-3F;;jHII I I I IRZ abb b b b b                    &(  ' ' ' '%*  * * * *"Q     
	9 	9 	9 	9 	9O O O O
 
 
 
   	+ 	+ 	+ 	+) ) ) )$ $ $ $       )      (   "< < < <@         '     
     
'         / / / /d% % % %$       (& & & &
? ? ? ? 68 7 7 7 7
 
 
 
 VX    @       , <7clh66" " " " "" " " "       
    
 
 
 
5 5 5 5   "   ! ! ! ! !H* * * *      I1 I1 I1 I1 I1 I1 I1 I1X   	 	 	 	c c c c, , , , 5 5 5 5   $ $ $ $"V V V V V,     s$   A A! A!%
A0 0A:9A: