
    i{                       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
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 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z"  G d d          Z#e$e%e&f         Z'e(e'         Z)e*e%e$e$e+e+f         e$e+e+f         dz  f         f         Z,de-d<   ddgZ.de-d<   e G d de                      Z/e%e/z  Z0 G d d          Z1 G d d          Z2 G d d          Z3dHd(Z4dId)Z5ej6        dJd,            Z7dKd.Z8dLd1Z9dMd3Z:dNd4Z;dOd:Z<ej=        dPd=            Z>	 dQdRdCZ?dSdDZ@dTdFZAdUdGZBdS )VzmLow-level infrastructure to find modules.

This builds on fscache.py; find_sources.py builds on top of this.
    )annotationsN)Enumunique)Final	TypeAlias)PathSpec)GitIgnorePatternError)pyinfo)CompileError)FileSystemCache)MypyFile)Options)stub_distribution_name)os_path_joinc                      e Zd ZddZdd
ZdS )SearchPathspython_pathtuple[str, ...]	mypy_pathpackage_pathtypeshed_pathreturnNonec                   t          t          t          j        j        |                    | _        t          t          t          j        j        |                    | _        t          t          t          j        j        |                    | _        t          t          t          j        j        |                    | _        d S N)	tuplemapospathabspathr   r   r   r   )selfr   r   r   r   s        P/root/projects/qq-shell/venv/lib64/python3.11/site-packages/mypy/modulefinder.py__init__zSearchPaths.__init__    s     !RW_k!B!BCCs27?I>>??!#bgo|"D"DEE"3rw#F#FGG    dict[str, tuple[str, ...]]c                8    | j         | j        | j        | j        dS )Nr   r   r   r   r'   r!   s    r"   asdictzSearchPaths.asdict0   s(    + -!/	
 
 	
r$   N)
r   r   r   r   r   r   r   r   r   r   )r   r%   )__name__
__module____qualname__r#   r)    r$   r"   r   r      s@        H H H H 
 
 
 
 
 
r$   r   
_TypeAliasStdlibVersions.pyi.pyr   PYTHON_EXTENSIONSc                  &    e Zd ZdZdZdZdZdd	Zd
S )ModuleNotFoundReasonr            daemonboolr   tuple[str, list[str]]c                
   d}| t           j        u rd}|g}nj| t           j        u rd}dg}nV| t           j        u rd}|g}nB| t           j        u r2d}dg}|s|                    d           |                    |           nJ ||fS )NzKSee https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-importszFCannot find implementation or library stub for module named "{module}"zOYou may be running mypy in a subpackage, mypy should be run on the package rootz`Skipping analyzing "{module}": module is installed, but missing library stubs or py.typed markerz*Library stubs not installed for "{module}"z*Hint: "python3 -m pip install {stub_dist}"zD(or run "mypy --install-types" to install all missing stub packages))r4   	NOT_FOUNDWRONG_WORKING_DIRECTORYFOUND_WITHOUT_TYPE_HINTSAPPROVED_STUBS_NOT_INSTALLEDappend)r!   r8   doc_linkmsgnotess        r"   error_message_templatesz,ModuleNotFoundReason.error_message_templatesY   s    `'111ZCJEE)AAAZCaEE )BBB%  JEE)FFF>CABE Z   LL""""LEzr$   N)r8   r9   r   r:   )r*   r+   r,   r<   r>   r=   r?   rD   r-   r$   r"   r4   r4   F   sG         I  !   $%      r$   r4   c                  *    e Zd ZdZ	 	 	 dddZddZdS )BuildSourcezA single source file.NFr   
str | Nonemoduletextbase_dirfollowedr9   r   r   c                P    || _         |pd| _        || _        || _        || _        d S )N__main__)r   rH   rI   rJ   rK   )r!   r   rH   rI   rJ   rK   s         r"   r#   zBuildSource.__init__~   s0     	*
	  r$   strc                j    d                     | j        | j        | j        d u| j        | j                  S )NzLBuildSource(path={!r}, module={!r}, has_text={}, base_dir={!r}, followed={}))formatr   rH   rI   rJ   rK   r(   s    r"   __repr__zBuildSource.__repr__   s4    Zaa	4;	(=t}dm 	
r$   )NNF)r   rG   rH   rG   rI   rG   rJ   rG   rK   r9   r   r   )r   rN   )r*   r+   r,   __doc__r#   rQ   r-   r$   r"   rF   rF   {   sR          #! ! ! ! !
 
 
 
 
 
r$   rF   c                  "    e Zd ZdZddZdd
ZdS )BuildSourceSetzIHelper to efficiently test a file's membership in a set of build sources.sourceslist[BuildSource]r   r   c                    d| _         i | _        t                      | _        |D ]S}|j        d| _         |j        r| j                            |j                   |j        r|j        pd| j        |j        <   Td S )NFT )source_text_presentsource_modulessetsource_pathsrI   r   addrH   )r!   rU   sources      r"   r#   zBuildSourceSet.__init__   s    #( .0&)ee 	G 	GF{&+/({ 3!%%fk222} G5;[5FB#FM2	G 	Gr$   filer   r9   c                V    |j         r|j         | j        v p|j        | j        v p| j        S r   )r   r\   	_fullnamerZ   rY   )r!   r_   s     r"   	is_sourcezBuildSourceSet.is_source   s8    Y949(99 (~!44('	
r$   N)rU   rV   r   r   )r_   r   r   r9   )r*   r+   r,   rR   r#   rb   r-   r$   r"   rT   rT      sF        SSG G G G
 
 
 
 
 
r$   rT   c                  ~    e Zd ZdZ	 	 d0d1dZd2dZd3dZd4dZd5dZddd6d Z	d7d"Z
d8d%Zd9d)Zd:d*Zd;d-Zd<d/ZdS )=FindModuleCacheaK  Module finder with integrated cache.

    Module locations and some intermediate results are cached internally
    and can be cleared with the clear() method.

    All file system accesses are performed through a FileSystemCache,
    which is not ever cleared by this class. If necessary it must be
    cleared by client code.
    Nsearch_pathsr   fscacheFileSystemCache | NoneoptionsOptions | Nonestdlib_py_versionsStdlibVersions | None
source_setBuildSourceSet | Noner   r   c                    || _         || _        |pt                      | _        i | _        i | _        i | _        || _        d }|r|j        }|pt          |          | _
        d S r   )re   rl   r   rf   initial_componentsresultsns_ancestorsrh   custom_typeshed_dirload_stdlib_py_versionsrj   )r!   re   rf   rh   rj   rl   rr   s          r"   r#   zFindModuleCache.__init__   s     )$3/"3"3 PR68,." 	>")"="4 #
8O9
 9
r$   c                    | j                                          | j                                         | j                                         d S r   )rp   clearro   rq   r(   s    r"   ru   zFindModuleCache.clear   sF    %%'''!!!!!r$   idrN   ModuleSearchResult | Nonec                ,     j         sdS  j         j                            |d          }|r j                            |          rt
          j                            |          t          |	                    d                    D ]E}t           fdt          D                       s dS t
          j                                      F|S |                    d          }|dk    r                     |d|                   t          t                    sdS t
          j                                      \  }}t          fdt          D                       s/|t          v r& j                            |          st$          j        S dS )zFast path to find modules by looking through the input sources

        This is only used when --fast-module-lookup is passed on the command line.N.c              3  n   K   | ]/}j                             t          d |z                       V  0dS r#   N)rf   isfiler   ).0xdr!   s     r"   	<genexpr>z=FindModuleCache.find_module_via_source_set.<locals>.<genexpr>   sR        MNDL''Q
Q(G(GHH     r$   c              3  H   K   | ]}                     d |z             V  dS r{   )endswith)r}   r~   parents     r"   r   z=FindModuleCache.find_module_via_source_set.<locals>.<genexpr>   s3      RR1vzA~66RRRRRRr$   )rl   rZ   getrf   r|   r   r   dirnamerangecountanyr2   rfindfind_module_via_source_set
isinstancerN   splitextisdirr4   r<   )	r!   rv   p_idxbasenameextr   r   s	   `      @@r"   r   z*FindModuleCache.find_module_via_source_set   s     	4O*..r488 	$$Q'' 	
 ""A288C==)) ' '     Rc        44GOOA&&Hhhsmm"99 44RX>>F~Z%<%<~tG,,V44MHcRRRR@QRRRRR 6(((1C1CH1M1M( ,55tr$   lib_pathr   PackageDirsc                L   |                     d          }t          j                            |dd                   }g }|                     ||d                   D ]H}|rt          ||          }n|}| j                            |          r|                    |df           I|S )zMFind which elements of a lib_path have the directory a module needs to exist.ry   Nr   r   T)	splitr   sepjoinget_toplevel_possibilitiesr   rf   r   r@   )r!   rv   r   
components	dir_chaindirspathitemdirs           r"   find_lib_path_dirsz"FindModuleCache.find_lib_path_dirs  s    XXc]]
FKK
3B300	77*Q-PP 	) 	)H "8Y77|!!#&& )S$K(((r$   	list[str]c                   || j         v r!| j         |                             |g           S i }|D ]}	 | j                            |          }n# t          $ r g }Y nw xY w|D ]P}t
          j                            |          d         }|                    |g           	                    |           Q|| j         |<   |                    |g           S )a  Find which elements of lib_path could contain a particular top-level module.

        In practice, almost all modules can be routed to the correct entry in
        lib_path by looking at just the first component of the module name.

        We take advantage of this by enumerating the contents of all of the
        directories on the lib_path and building a map of which entries in
        the lib_path could contain each potential top-level module that appears.
        r   )
ro   r   rf   listdirOSErrorr   r   r   
setdefaultr@   )r!   r   rv   r   r   contentsnames          r"   r   z*FindModuleCache.get_toplevel_possibilities  s     t...*8488R@@@ ,.
 
	< 
	<C<//44   
 ! < <w''--a0%%dB//66s;;;;< -7)~~b"%%%s   AAAF	fast_pathr   r9   ModuleSearchResultc                  || j         vr|                    d          d         }d}|| j        v r|                     |          }n|| j        v r|                     |          }|                     ||          \  }}|rd|sK| j        | j        j        s8|t          j        u r*| 	                    |          rt          j
        | j         |<   n
|| j         |<   | j         |         S |S | j         |         S )zReturn the path of the module source file or why it wasn't found.

        If fast_path is True, prioritize performance over generating detailed
        error descriptions.
        ry   r   T)rp   	partitionrj   _typeshed_has_version_find_modulerh   fast_module_lookupr4   r<   _can_find_module_in_parent_dirr=   )r!   rv   r   	top_leveluse_typeshedresultshould_caches          r"   find_modulezFindModuleCache.find_module5  s    T\!!S))!,ILT,,,#99"==d555#99)DD#'#4#4R#F#F FL  "	.&*l&>4<Cb&>"6"@@@;;B?? A (<'SDL$$'-DL$|B''|Br$   rH   c                |    | j         sdS t          | j                   }| j        |         \  }}||k    o	|d u p||k    S )NT)rh   typeshed_py_versionrj   )r!   rH   versionmin_versionmax_versions        r"   r   z%FindModuleCache._typeshed_has_versionS  sQ    | 	4%dl33#'#:6#B [+%Y;$+>+X'[BXYr$   pkg_dir$OnePackageDir | ModuleNotFoundReasonc                   d}|}|                     d          }t          |          D ]\  }}t          ||          }| j                            t          |d                    r't          j        j        |g|d d         R  |dk    fc S |s9| j                            |          s| j                            |dz             rd}| j                            |          s n|rU| j	        rB| j	        
                    |          }|j        r!t          j        j        |g|d d         R  dfS t          j        S t          j        S )NFry   py.typedr   r   r1   T)r   	enumerater   rf   r|   r   r   r   r   rh   clone_for_modulefollow_untyped_importsr4   r>   r<   )	r!   rv   r   plausible_matchdir_pathr   index	componentmodule_specific_optionss	            r"   _find_module_non_stub_helperz,FindModuleCache._find_module_non_stub_helperZ  so     XXc]]
 )* 5 5 
	 
	E9#Hi88H|""<*#E#EFF 'w|G>j"o>>>
JJJJ$ '""8,,'040C0CHuDT0U0U' #'<%%h//  	2| J*.,*G*G*K*K'*A J7<B*SbS/BBBEII'@@'11r$   r   matchtuple[str, bool]c                $   |\  }}t          dt          |                    D ]l}d                    |d |                    }|| j        vr$| j                            |          r
|| j        |<   t          j                            |          }md S )Nr5   ry   )	r   lenr   rq   rf   r   r   r   r   )r!   r   r   r   verifyipkg_ids          r"   _update_ns_ancestorsz$FindModuleCache._update_ns_ancestorst  s    fq#j//** 	) 	)AXXj1"o..FT...4<3E3Ed3K3K.,0!&)7??4((DD		) 	)r$   c                   t          j                    }t          t          dddd          | j        | j        | j                  }t          d t          j        |          D                       rt           j	        
                    |          }t          |fddd          |_        t          |                    |d          d         t                    sdS t          d t          j        |          D                       dS )zsTest if a module can be found by checking the parent directories
        of the current working directory.
        r-   )rj   c              3  4   K   | ]}t          |          V  d S r   )is_init_file)r}   r_   s     r"   r   zAFindModuleCache._can_find_module_in_parent_dir.<locals>.<genexpr>  s*      II,t$$IIIIIIr$   Fr   T)r   getcwdrd   r   rf   rh   rj   r   r   r   r   re   r   r   r4   )r!   rv   working_dirparent_searchs       r"   r   z.FindModuleCache._can_find_module_in_parent_dir|  s     ikk'BB''LL#6	
 
 
 IIK1H1HIIIII 	'//+66K)4k^RR)P)PM&m88UCCAFH\]] t	 IIK1H1HIIIII 	
 ur$   r   tuple[ModuleSearchResult, bool]c                l   &  j         & j        ! j        j        r                               nd}|r|dfS                     d          }t
          j                            |dd                   }g }g }d} fd|d         |d         dz   fD             }	d}
 j        j	        D ]}||	vr|d         dz   }t          ||          }&                    |          rt          |d	          }|g|d
d         z   }t          j        j        |g|dd         R  }&                    |          r&                    |          r&                    |                                                                          dk    r?t          ||          }|                    |df           |                    |df           n/|                    |df           n|                    |df                                |          }t'          |t(                    r|t(          j        u rd}d}
|                    |                                ||            j        r6 j        j        r*|                                 |                                 d} j        j         j        j        z   }                     |          }|r#|                      j        j                  z  }|||z   z  }t
          j        |d         z   }t
          j        dz   }g }|D ]\  }}||z   }d}|}t;          t=          |          d
z
            D ]!}t
          j                            |          }"| d| d}&                     ||          r2|r*tC          &||          s|                    ||f           n|dfc S tD          D ]V}||z   |z   }&                     ||          r6d}|r*tC          &||          s|                    ||f           N|dfc c S W j        rQ j        j#        rE|sC&$                    ||          r-&                     ||          s|                    ||f           tD          D ]Q}||z   }&                     ||          r4|r*tC          &||          s|                    ||f           I|dfc c S R j        rO j        j#        rC|rA&fd|D             } | %                    tM          |                     }!||!         d         dfS  j'        (                              }"|"|"dfS tS                    }#|#rt=          |          d
k    rt(          j*        dfS t;          d
t=          |                    D ]4}$d                    |d|$                   }%tS          |%          |#k    r n5t(          j*        dfS  +                    |%          t(          j*        u rt(          j*        dfS t(          j,        dfS |rt(          j        |
fS t(          j,        dfS )zwTry to find a module in all available sources.

        Returns:
            ``(result, can_be_cached)`` pair.
        NTry   r   Fc                f    h | ]-}                     |j        j                  D ]
}|d          .S )r   )r   re   r   )r}   r   package_dirr!   s      r"   	<setcomp>z/FindModuleCache._find_module.<locals>.<setcomp>  sZ     "
 "
 "
#66y$BSB`aa"
 "
  N"
 "
 "
 "
r$   r   z-stubsr   r5   partialr#   r0   c                :    g | ]\  }}t          ||          S r-   )highest_init_level)r}   r   
dir_prefixrf   rv   s      r"   
<listcomp>z0FindModuleCache._find_module.<locals>.<listcomp>H  s;       $D* #7BjAA  r$   )-rf   rh   r   r   r   r   r   r   re   r   r   r   r   r|   readdecodestripr@   r   r   r4   r>   r   use_builtins_fixturesru   r   r   r   r   r   r   r   isfile_caseverify_moduler2   namespace_packagesexists_caser   maxrq   r   r   r?   r   r<   )'r!   rv   r   r   r   r   third_party_inline_dirsthird_party_stubs_dirs-found_possible_third_party_missing_type_hintscandidate_package_dirscan_cache_any_resultr   	stub_namestub_dirstub_typed_filestub_componentsr   runtime_pathnon_stub_matchpython_mypy_pathcandidate_base_dirsseplastsepinitnear_missesrJ   r   	base_pathhas_initr   r   
path_stubs	extensionlevelsr   ancestorapproved_dist_namer   	parent_idrf   s'   ``                                    @r"   r   zFindModuleCache._find_module  s    ,> (T\-L( ++B/// 	

  	d7N XXc]]
FKK
3B300	 02.08=5"
 "
 "
 "
(mZ]X-EF"
 "
 "
  $(5 "	F "	FG444"10I#GY77H}}X&& D".x"D"D#,+
122">w|GCocrc.BCCC==&& D~~o66 D
 #<<88??AAGGIIYVV+7+K+KL3::L$;OPPP 3994-HHHH 3994,GGGG.55tTlCCC!>>r7KKN.*>?? F!%9%RRRDHA+0('..~>>>))*nEEEE< 	BDL> 	B#))+++"((***<A9,69J9VV"55b:JKK 	`  4#:#:2t?P?^#_#__58OOO &:b>)&:% 3 )	& )	&Hf 7*IH!J3z??Q.// 9 9W__Z88

 &::W:::J"":z:: , ,-Z"T"T ,&&
J'?@@@@%t++++ / & &	 7*Y6&&tZ88 &#H !mGRz&R&R !#**D*+=>>> :%%%%%& | @ ? @ @++IzBB@ $//	:FF@
  &&	:'>??? / & &	 9,&&tZ88 & !mGRz&R&R !#**D*+=>>> :%%%%%	&&: < 	/DL; 	/ 	/    (3  F LLV--Eu%a($.. $((,,T>!3B77 	8:!##+H$NN 1c*oo.. O OHHZ^44	))448JJJE K ,H$NN	**.B.___+H$NN'14778 	W'@BVVV#-t33r$   rV   c                R   |                      |d          }t          |t                    rg S t          ||d           g}d }t	          |          r t
          j                            |          }n| j        	                    |          r|}||S t                      }t          | j                            |                    }|D ]}|dv s|                    d          rt          ||          }| j        r0t!          || j        j        | j        | j        j        dk              rd| j        r1| j        j        r%t)          || j        | j        j        dk              r| j        	                    |          r| j        r| j        j        sP| j                            t          |d                    s(| j                            t          |d                    rC|                    |           |                    |                     |dz   |z                        ^t
          j                            |          \  }	}
|	dk    r|	|vrPd|	vrL|
t6          v rC|                    |	           |                    |                     |dz   |	z                        |S )	NTr   )__pycache__zsite-packagesnode_modulesry   r6   __init__.py__init__.pyir#   )r   r   r4   rF   r   r   r   r   rf   r   r[   sortedr   
startswithr   rh   matches_excludeexclude	verbosityexclude_gitignorematches_gitignorer   r|   r]   extendfind_modules_recursiver   r2   )r!   rH   module_pathrU   r   seennamesr   subpathstemsuffixs              r"   r  z&FindModuleCache.find_modules_recursivek  s   &&v&>>k#788 	I{FD99:$$ 	'7??;77LL\,, 	'&LN t|++L99:: !	U !	UDGGG4??[^K_K_G"<66G| -t|T\=SWX=X! !  L2 &gt|T\=SWX=XYY
 |!!'** UL UT\%D UL''Wm(L(LMMU|**<+P+PQQU HHTNNNNN4#>#>v|d?R#S#STTT!w//55f:%%t##4FFW<W<W HHTNNNNN4#>#>v|d?R#S#STTTr$   )NN)re   r   rf   rg   rh   ri   rj   rk   rl   rm   r   r   )r   r   )rv   rN   r   rw   )rv   rN   r   r   r   r   )r   r   rv   rN   r   r   )rv   rN   r   r9   r   r   )rH   rN   r   r9   )rv   rN   r   rN   r   r   )r   r   r   r   r   r   )rv   rN   r   r9   )rv   rN   r   r9   r   r   )rH   rN   r   rV   )r*   r+   r,   rR   r#   ru   r   r   r   r   r   r   r   r   r   r  r-   r$   r"   rd   rd      s4         59,0
 
 
 
 
2" " " "
/ / / /b    & & & &> 9>            <Z Z Z Z2 2 2 24) ) ) )   $[4 [4 [4 [4z7 7 7 7 7 7r$   rd   r  rN   excludesr   rf   r   verboser9   r   c                    |sdS t           j                            |                               t           j        d          }|                    |           r|dz  }|D ]}	 t          j        ||          r'|r"t          d| d| dt          j
                    dS @# t          j        $ rN}t          d| d	| d
|v rdndz   dz   dz   t          j
                   t          j        d           Y d }~d }~ww xY wdS )NF/TRACE: Excluding z (matches pattern )r_   Tzerror: The exclude z, is an invalid regular expression, because: \z>
(Hint: use / as a path separator, even if you're on Windows!)rX   z7
For more information on Python's flavor of regex, see:z* https://docs.python.org/3/library/re.htmlr6   )r   r   relpathreplacer   r   researchprintsysstderrerrorexit)r  r  rf   r  subpath_strr	  es          r"   r  r    sk     u'//'**22263??K}}W s  	y+..  UKUU7UUU Z    tt x 	 	 	^g^^[\^^ w VU	 MM ?? Z
 
 
 
 HQKKKKKKKK	 5s   !9BC;-AC66C;c                ^   t           j                            |           \  }}t          |          D ]z\  }}t           j                            | |          }|                    |          r|dz   }|                    |          r&|r!t          d| d| t          j	                    dS {dS )Nr  r  z (matches .gitignore) in r  TF)
r   r   r   find_gitignoresr  r   
match_filer!  r"  r#  )r  rf   r  r   r   gi_pathgi_specrelative_paths           r"   r  r    s    W]]7##FC+C00 
 
99=='' 	0)C/Mm,, 	 YYYPWYY    44	 5r$   r   list[tuple[str, PathSpec]]c                z   t           j                            |           }|| k    s=t           j                            t           j                            | d                    rg }nt          |          }t           j                            | d          }t           j                            |          rt          |          5 }|                                }d d d            n# 1 swxY w Y   	 || t          j
        d|          fgz   S # t          $ r# t          d| t          j                   |cY S w xY w|S )Nz.gitz
.gitignore	gitignorezerror: could not parse r  )r   r   r   existsr   r)  r|   open	readlinesr   
from_linesr	   r!  r"  r#  )r   
parent_dirparent_gitignoresr0  fliness         r"   r)  r)    sb   %%JSBGNN27<<V+D+DEE+J77S,//I	w~~i   %)__ 	"KKMME	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"	%$h.A+u.U.U(V'WWW$ 	% 	% 	%7I77cjIIII$$$$	% s$   C$$C(+C(0D *D87D8r   c                D    t           j                            |           dv S )N)r  r  )r   r   r   )r   s    r"   r   r     s    7D!!%DDDr$   rv   prefixc                :    t                    rt          j                                      t	          |                    d                    D ]F}t          j                                      t           fdt          D                       s dS GdS )z;Check that all packages containing id have a __init__ file.ry   c              3  f   K   | ]+}                     t          d |                     V  ,dS r{   r   r   r}   r   rf   r   r:  s     r"   r   z verify_module.<locals>.<genexpr>  sZ       
 
 T3Ii3I3I J JFSS
 
 
 
 
 
r$   FTr   r   r   r   r   r   r   r2   )rf   rv   r   r:  r   s   ` `` r"   r   r     s    D %wt$$288C==!!  wt$$ 
 
 
 
 
 
.
 
 
 
 
 	 55		
 4r$   intc                B    t                    rt          j                                      d}t	          |                    d                    D ]H}t          j                                      t           fdt          D                       r|dz   }I|S )z:Compute the highest level where an __init__ file is found.r   ry   c              3  f   K   | ]+}                     t          d |                     V  ,dS r{   r=  r>  s     r"   r   z%highest_init_level.<locals>.<genexpr>  sZ       
 
 T3Ii3I3I J JFSS
 
 
 
 
 
r$   r5   r?  )rf   rv   r   r:  levelr   s   ` ``  r"   r   r     s    D %wt$$E288C==!!  wt$$ 
 
 
 
 
 
.
 
 
 
 
 	 EELr$   c                 p    t          j        d          } | sg S |                     t           j                  S )NMYPYPATH)r   getenvr   pathsep)path_envs    r"   r   r     s2    y$$H 	>>"*%%%r$   data_dir	pyversiontuple[int, int]rr   rG   c                D   t           j                            |           } g }|r"t           j                            |          }t           j                            |d          }t           j                            |dd          }t           j                            |dd          }t           j                            |d          }t           j                            |          rt           j                            |          sBt          d                    |          t          j	                   t          j
        d           nt           j                            | d	          }t           j                            |          r|} t           j                            | d
d          }t           j                            | d
dd          }t           j                            | d
dd          }|                    |           |                    |           |                    |           t          j        dk    r|                    d           |sMt          d                    t          j        |           t          j	                   t          j
        d           |S )zJReturn default standard library search paths. Guaranteed to be normalised.stdlibstubszmypy-extensionslibrtVERSIONSzDerror: --custom-typeshed-dir does not point to a valid typeshed ({})r  r6   z
stubs-autotypeshedwin32z/usr/local/lib/mypyz~Could not resolve typeshed subdirectories. Your mypy install is broken.
Python executable is located at {}.
Mypy located at {}r5   )r   r   r    r   r   r|   r!  rP   r"  r#  r%  r@   platform
executable)	rI  rJ  rr   r   typeshed_dirmypy_extensions_dir	librt_dirversions_fileautos	            r"   default_lib_pathrZ    s4   
 wx((HD I goo.ABBw||$7BB gll+>IZ[[GLL!4gwGG	\:>>w}}\** 	"'..2O2O 	V]]'  Z	    HQKKKw||Hl337== 	Hw||Hj(CC gll8ZJ[\\GLL:wHH	KK 	KK#$$$KK	 |w)*** FFLfG G 	
 	
 	
 	
 	Kr$   python_executabletuple[list[str], list[str]]c                \   | g g fS | t           j        k    rt          j                    \  }}ni t	          t
          j                  ddi}	 t          j        t          j
        | t          j        dg|t          j                                                            \  }}n# t          j        $ r.}t          |j                   t          |j                    d}~wt$          $ r>}|j        J t          j        |j                  }t+          d|  d| g          |d}~ww xY w||fS )a  Find package directories for given python. Guaranteed to return absolute paths.

    This runs a subprocess call, which generates a list of the directories in sys.path.
    To avoid repeatedly calling a subprocess (which can be slow!) we
    lru_cache the results.
    NPYTHONSAFEPATH1getsearchdirs)envr#  z!mypy: Invalid python executable 'z': )r"  rT  r
   r`  dictr   environastliteral_eval
subprocesscheck_output__file__PIPEr   CalledProcessErrorr!  r#  stdoutr   errnostrerrorr   )r[  sys_pathsite_packagesra  errreasons         r"   get_search_dirsrr  E  s]     Bx	cn	,	,"("6"8"8-- :bj!!9#3S99	&)&6'&I%?   &((' '#Hmm , 	 	 	#*#* 	 	 	9((([++FS5FSS6SST 	 ]""s%   AB$ $D'3)CD')9D""D'rU   rV   rh   r   alt_lib_pathc                6   t          j        t          ||j        |j                            }|j        rt          j        dd          }|sAt          j        	                    t          j        	                    t                              }t          j                            |          }|                    t          j                            |ddd                     g }|sc| D ])}|j        r |j        }||vr|                    |           *|j        rd}nt          j                    }||vr|                    d|           t'                      }	|	                    |j                   |r|	                    d|           t+          |j                  \  }
}|D ]|vsJ |	v sGt/          fd	|	D                       s,t          j        j        rht/          fd
|	D                       rMt3           dt4          j                   t3          dt4          j                   t5          j        d           t;          t=          t?          |                    t=          |	          t=          |
|z             t=          |                    S )a/  Compute the search paths as specified in PEP 561.

    There are the following 4 members created:
    - User code (from `sources`)
    - MYPYPATH (set either via config or environment variable)
    - installed package directories (which will later be split into stub-only and inline)
    - typeshed
    )rr   MYPY_TEST_PREFIXNz	test-dataunitzlib-stubry   r   c              3  f   K   | ]+}|                     t          j        j        z             V  ,d S r   )r  r   r   r   r}   r   sites     r"   r   z'compute_search_paths.<locals>.<genexpr>  s8      FF1<<rw{ 233FFFFFFr$   c              3  f   K   | ]+}|                     t          j        j        z             V  ,d S r   )r  r   r   altseprx  s     r"   r   z'compute_search_paths.<locals>.<genexpr>  s8      &]&]qq||D27>4I'J'J&]&]&]&]&]&]r$   z& is in the MYPYPATH. Please remove it.r  zbSee https://mypy.readthedocs.io/en/stable/running_mypy.html#how-mypy-handles-imports for more infor5   r'   ) collectionsdequerZ  python_versionrr   r   r   rF  r   r   rh  r    
appendleftr   rJ   r@   bazelr   insertr   r  rr  r[  r   r{  r!  r"  r#  r%  r   r   reversed)rU   rh   rI  rs  r   root_dirr   r^   r   mypypathrn  ro  ry  s               @r"   compute_search_pathsr  l  s     g,'B]	
 	
 	
 H $ 	U
 9/66 	Bwrwx'@'@AAH7??8,,BGLL;
SSTTT  K ' 	, 	,F ,ok))&&s+++ = 	CC)++Chq#&&& {{H OOG%&&&  )<(((-g.GHHHm  8####HFFFFXFFFFF  #&&]&]&]&]T\&]&]&]#]#]  TAAA
SSSS:Z   
 HQKKK(;//00//8m344Hoo	   r$   c                   | p1t          t          j                            t                    d          }t          |d          }i }t          |d          }t          j                            |          sJ | |t          f            t          |          5 }|D ]}|                    d          d                                         }|dk    r6|                    d          \  }}|                    d          }	t          |	d                   }
t          |	          d	k    r/|	d
                                         rt          |	d
                   nd}|
|f||<   	 ddd           n# 1 swxY w Y   |S )zReturn dict with minimum and maximum Python versions of stdlib modules.

    The contents look like
    {..., 'secrets': ((3, 6), None), 'symbol': ((2, 7), (3, 9)), ...}

    None means there is no maximum version.
    rQ  rM  rP  #r   rX   :-r6   r5   N)r   r   r   r   rh  r|   r2  r   r   parse_versionr   )rr   rU  
stdlib_dirr   versions_pathr7  linerH   version_rangeversionsr   r   s               r"   rs   rs     s    '],rwx7P7PR\*]*]LlH55JF Z88M7>>-((XX+>x*XXXX	m		 6 
	6 
	6D::c??1%++--Drzz$(JJsOO!FM$**3//H'44K.1(mmq.@.@Xa[EVEVEXEX.@hqk***^b  )+5F6NN
	66 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Ms   CE++E/2E/r   c                    |                                                      d          \  }}t          |          t          |          fS )Nry   )r   r   r@  )r   majorminors      r"   r  r    s8    ==??((--LE5u::s5zz!!r$   c                ,    t          | j        d          S )zIReturn Python version used for checking whether module supports typeshed.)r7   	   )r   r~  )rh   s    r"   r   r     s     w%v...r$   )
r  rN   r  r   rf   r   r  r9   r   r9   )r  rN   rf   r   r  r9   r   r9   )r   rN   r   r.  )r   rN   r   r9   )
rf   r   rv   rN   r   rN   r:  rN   r   r9   )
rf   r   rv   rN   r   rN   r:  rN   r   r@  )r   r   )rI  rN   rJ  rK  rr   rG   r   r   )r[  rG   r   r\  r   )
rU   rV   rh   r   rI  rN   rs  rG   r   r   )rr   rG   r   r/   )r   rN   r   rK  )rh   r   r   rK  )CrR   
__future__r   rd  r|  	functoolsr   r  rf  r"  enumr   r   typingr   r   r.   pathspecr   pathspec.patterns.gitignorer	   mypyr
   mypy.errorsr   mypy.fscacher   
mypy.nodesr   mypy.optionsr   mypy.stubinfor   	mypy.utilr   r   r   rN   r9   OnePackageDirlistr   rb  r@  r/   __annotations__r2   r4   r   rF   rT   rd   r  r  	lru_cacher)  r   r   r   r   rZ  cacherr  r  rs   r  r   r-   r$   r"   <module>r     s    
 # " " " " " 



         				 				     



         1 1 1 1 1 1 1 1       = = = = = =       $ $ $ $ $ $ ( ( ( ( ( (                   0 0 0 0 0 0 " " " " " "
 
 
 
 
 
 
 
6 c4i =! "#uU38_eCHoPT>T-T'U"UV V V V V"E?  * * * * , , , , ,4 , , ,b // 
 
 
 
 
 
 
 
2
 
 
 
 
 
 
 
0v v v v v v v vr   B        &E E E E      & & & &0 0 0 0f ## ## ## ##N ]aU U U U Up   :" " " "
/ / / / / /r$   