ML iUdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z ddl mZmZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd l m!Z!ddl"m#Z#ddl$m%Z%GddZ&e'e(e)fZ*e+e*Z,e-e(e'e'e.e.fee'e.e.fffZ/de0d<ddgZ1de0d<e Gdde Z2ee(e2fZ3GddZ4GddZ5GddZ6 d-d Z7d.d!Z8ejrd/d"Z:d0d#Z;d1d$Z d4d'Z?ejd5d(ZA d6 d7d)ZBd8d*ZCd9d+ZDd:d,ZEy);zmLow-level infrastructure to find modules. This builds on fscache.py; find_sources.py builds on top of this. ) annotationsN)Enumunique)FinalOptionalUnion) TypeAlias)PathSpec)GitWildMatchPatternError)pyinfo) CompileError)FileSystemCache)MypyFile)Options)stub_distribution_name) os_path_joinc0eZdZ ddZddZy) SearchPathsctttjj||_tttjj||_tttjj||_tttjj||_yN) tuplemapospathabspath python_path mypy_path package_path typeshed_path)selfrrrrs W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypy/modulefinder.py__init__zSearchPaths.__init__!ss!RWW__k!BCs277??I>?!#bggoo|"DE"3rww #FGc`|j|j|j|jdS)Nrrrrr%r s r!asdictzSearchPaths.asdict1s.++ --!//   r#N) rtuple[str, ...]rr(rr(rr(returnNone)r)zdict[str, tuple[str, ...]])__name__ __module__ __qualname__r"r'r#r!rr sBH$H#H& H ' H  H  r#r _TypeAliasStdlibVersions.pyi.pyrPYTHON_EXTENSIONSc$eZdZdZdZdZdZddZy)ModuleNotFoundReasonrc*d}|tjur d}|g}||fS|tjur d}dg}||fS|tjur d}|g}||fS|tjur-d}dg}|s|j d|j |||fSJ)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))r5 NOT_FOUNDWRONG_WORKING_DIRECTORYFOUND_WITHOUT_TYPE_HINTSAPPROVED_STUBS_NOT_INSTALLEDappend)r daemondoc_linkmsgnotess r!error_message_templatesz,ModuleNotFoundReason.error_message_templatesZs` '11 1ZCJE,Ez+)AA AZCaE&Ez!)BB B% JEEz)FF F>CABE Z LL "Ez 5r#N)r?boolr)ztuple[str, list[str]])r+r,r-r:r<r;r=rCr.r#r!r5r5Gs&I ! $% r#r5c>eZdZdZ d ddZddZy) BuildSourcezA single source file.NcR||_|xsd|_||_||_||_y)N__main__)rmoduletextbase_dirfollowed)r rrIrJrKrLs r!r"zBuildSource.__init__s, *       r#cdj|j|j|jdu|j|j S)NzLBuildSource(path={!r}, module={!r}, has_text={}, base_dir={!r}, followed={}))formatrrIrJrKrLr&s r!__repr__zBuildSource.__repr__s9 Z a a 4;; (=t}}dmm  r#)NNF) r str | NonerIrPrJrPrKrPrLrDr)r*)r)str)r+r,r-__doc__r"rOr.r#r!rFrF|sT  # ! ! ! !  !  !  ! r#rFc eZdZdZddZddZy)BuildSourceSetzIHelper to efficiently test a file's membership in a set of build sources.c<d|_i|_t|_|D]z}|jd|_|j r%|jj |j |jsT|j xsd|j|j<|y)NFT)source_text_presentsource_modulesset source_pathsrJraddrI)r sourcessources r!r"zBuildSourceSet.__init__s#( .0&)e GF{{&+/({{!!%%fkk2}}5;[[5FB##FMM2  Gr#c|jxr|j|jvxs&|j|jvxs |jSr)rrZ _fullnamerXrW)r files r! is_sourcezBuildSourceSet.is_sourcesG YY 9499(9(99 (~~!4!44 ('' r#N)r\list[BuildSource]r)r*)r`rr)rD)r+r,r-rRr"rar.r#r!rTrTsS G r#rTceZdZdZ d ddZddZddZddZddZdd dd Z dd Z dd Z dd Z ddZ ddZddZy)FindModuleCacheaKModule 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. Nc||_||_|xs t|_i|_i|_i|_||_d}|r |j}|xs t||_ yr) search_paths source_setrfscacheinitial_componentsresults ns_ancestorsoptionscustom_typeshed_dirload_stdlib_py_versionsstdlib_py_versions)r rfrhrlrorgrms r!r"zFindModuleCache.__init__sq)$3/"3 PR68 ,. " ")"="= "4# 8O 9 r#c|jj|jj|jjyr)rjclearrirkr&s r!rqzFindModuleCache.clears6  %%' !r#cjsyjjj|d}|rjj |rzt j j|t|jdD]<}tfdtDsyt j j>|S|jd}|dk7rj|d|ttsyt j j!\}}tfdtDs3|tvr+jj#|st$j&Sy)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.c3nK|],}jjtd|z.ywr"N)rhisfiler).0xdr s r! z=FindModuleCache.find_module_via_source_set..s0MNDLL'' Q Q(GHs25c3FK|]}jd|zywru)endswith)rwrxparents r!rzz=FindModuleCache.find_module_via_source_set..sR1vzA~6Rs!)rgrXgetrhrvrrdirnamerangecountanyr3rfindfind_module_via_source_set isinstancerQsplitextisdirr5r:) r idp_idxbasenameextryr~s ` @@r!rz*FindModuleCache.find_module_via_source_sets1 OO * * . .r4 8 $$Q' "A288C=) 'Rc GGOOA&  ' Hhhsm "944RX>F~Z%<GG,,V4MHcR@QRR((1C1CH1M,555r#c$|jd}tjj|dd}g}|j ||dD]B}|r t ||}n|}|j j|s0|j|dfD|S)zMFind which elements of a lib_path have the directory a module needs to exist.rsNr{rT) splitrsepjoinget_toplevel_possibilitiesrrhrr>)r rlib_path components dir_chaindirspathitemdirs r!find_lib_path_dirsz"FindModuleCache.find_lib_path_dirssXXc] FFKK 3B0 77*Q-P )H"8Y7||!!#& S$K( ) r#c||jvr|j|j|gSi}|D]h} |jj|}|D]E}t j j|d}|j|gj|Gj||j|<|j|gS#t$rg}YzwxYw)aFind 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) rirrhlistdirOSErrorrrr setdefaultr>)r rrrrcontentsnames r!rz*FindModuleCache.get_toplevel_possibilitiess t.. .**8488R@ @,.  > C  C F fast_pathc||jvr|jdd}d}||jvr|j|}n||jvr|j|}|j ||\}}|r|sc|j |j j sA|tjur/|j|rtj|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. rsrT) rj partitionro_typeshed_has_version _find_modulerlfast_module_lookupr5r:_can_find_module_in_parent_dirr;)r rr top_level use_typeshedresult should_caches r! find_modulezFindModuleCache.find_module6s T\\ ! S)!,ILT,,,#99"= d555#99)D #'#4#4R#F FL"dll&>4<+X'[BXYr#cd}|}|jd}t|D]\}}t||}|jj t|dr*t j j|g|dd|dk(fcS|s;|jj|s|jj |dzrd}|jj|rn|rh|jrL|jj|}|jr%t j j|g|dddfStjStjS)NFrspy.typedr{rr2T)r enumeraterrhrvrrrrrlclone_for_modulefollow_untyped_importsr5r<r:) r rpkg_dirplausible_matchdir_pathrindex componentmodule_specific_optionss r!_find_module_non_stub_helperz,FindModuleCache._find_module_non_stub_helper[s* XXc] )* 5  E9#Hi8H||""<*#EFww||G>j"o> JJ$ ""8, 0C0CHuDT0U"&<<%%h/  ||*.,,*G*G*K'*AA77<<B*Sb/BEII'@@ @'11 1r#c|\}}tdt|D]n}dj|d| }||jvr*|jj |r||j|<t jj|}py)Nr6rs) rlenrrkrhrrrr)r rmatchrverifyipkg_ids r!_update_ns_ancestorsz$FindModuleCache._update_ns_ancestorsus| fq#j/* )AXXj1"o.FT...4<<3E3Ed3K,0!!&)77??4(D  )r#ctj}ttdddd|j|j |j }tdtj|Dr}tjj|}t|fddd|_ t|j|ddtsytdtj|Dr}y)zsTest if a module can be found by checking the parent directories of the current working directory. r.)roc32K|]}t|ywr) is_init_file)rwr`s r!rzzAFindModuleCache._can_find_module_in_parent_dir..sI,t$IsFrT)rgetcwdrdrrhrlrorrrrrfrrr5)r r working_dir parent_searchs r!rz.FindModuleCache._can_find_module_in_parent_dir}siik ' BB ' LL LL#66  IK1HII''//+6K)4k^RR)PM &m88UCAFH\] IK1HII r#c  |j}|j'|jjr|j|nd}|r|dfS|j d}t j j|dd}g}g}d} |d|ddzfD chc]2} |j| |jjD]} | d 4} } } d} |jjD]p}|| vr |ddz}t||}|j|rt|d}|g|d dz}t jj|g|dd}|j|r|j|rw|j|j!j#d k(r3t||}|j%|df|j%|dfn'|j%|dfn|j%|df|j'||}t)|t*r|t*j,usHd} d} N|j%||j/||s|jr8|jj0r"|j3|j3d} |jj4|jj6z}|j||}|r)||j||jj8z }|||zz }t j |dz}t j d z}g}|D]\}}||z}d}|}t;t=|d z D]!} t jj?|}#|d|d }!|jA|!|r*|r"tC|||!|s|j%|!|fn|!dfcStDD]J}"||z|"z}|jA||sd}|r"tC||||s|j%||fD|dfccS|jrO|jjFr9|s7|jI||r%|jA||s|j%||ftDD]E}"||"z}|jA||s|r"tC||||s|j%||f?|dfccS|jr\|jjFrF|rD|Dcgc]\}}tK||||}#}}|#jMtO|#}$||$ddfS|jPjS|}%|%|%dfStU|}&|&rt=|d k(rt*jVdfSt;d t=|D]&}'dj|d|'}(tU|(|&k(s&nt*jVdfS|jY|(t*jVurt*jVdfSt*jZdfS| rt*j,| fSt*jZdfScc} } wcc}}w) zwTry to find a module in all available sources. Returns: ``(result, can_be_cached)`` pair. NTrsr{Frz-stubsrr6partialr"r1).rhrlrrrrrrrrfrrrrrvreaddecodestripr>rrr5r<ruse_builtins_fixturesrqrrrrrr isfile_case verify_moduler3namespace_packages exists_casehighest_init_levelrmaxrkrrr=rr:))r rrrhrrrthird_party_inline_dirsthird_party_stubs_dirs-found_possible_third_party_missing_type_hintsr package_dircandidate_package_dirscan_cache_any_resultr stub_namestub_dirstub_typed_filestub_componentsr runtime_pathnon_stub_matchpython_mypy_pathcandidate_base_dirsseplastsepinit near_missesrKr base_pathhas_init dir_prefixr path_stubs extensionlevelsrancestorapproved_dist_namer parent_ids) r!rzFindModuleCache._find_modulesr ,,> (T\\-L-L  + +B / d7N XXc] FFKK 3B0 02.08=5)mZ]X-EF" #66y$BSBSB`B`a"  N" " "  $((55" FG44"1 0I#GY7H}}X&".x"D#,+ 12">ww||GCocr.BC==&~~o6 #<<8??AGGIYV+7+KL3::L$;OP3994-H3994,G.55tTlC!>>r7KN.*>?!%9%R%RRDHA+0('..~>))*nEE" FH <> # ) ) + " ( ( *)&&:% 3) & Hf 7*IH!J3z?Q./ 9WW__Z8  9&;fWIT:J"":z:-Z"T&& J'?@%t++/ &  7*Y6&&tZ8#HmGRz&R#**D*+=> :% &|| ? ? ++IzB#// :F&& :'>?/ &  9,&&tZ8mGRz&R#**D*+=> :%  &G) &@ < !3B7 :!#+HH$NN1c*o. OHHZ^4 ))48JJ O ,HH$NN *.B._.__+HH$NN'1147 7 8'@@BVV V#--t33G" Ds 7X91X?cl|j|d}t|trgSt||dg}d}t |r t j j|}n|jj|r|}||St}t|jj|}|D]}|dvs|jdrt||}|jrDt!||jj"|j|jj$dk\rv|jrE|jj&r/t)||j|jj$dk\r|jj|r|jr|jj*sL|jj-t|ds'|jj-t|dsP|j/||j1|j3|dz|zt j j5|\} } | dk(r| |vsd| vs| t6vs|j/| |j1|j3|dz| z|S) NTr) __pycache__z site-packages node_modulesrsr7 __init__.py __init__.pyir")rrr5rFrrrrrhrrYsortedr startswithrrlmatches_excludeexclude verbosityexclude_gitignorematches_gitignorerrvr[extendfind_modules_recursiverr3) r rI module_pathr\rseennamesrsubpathstemsuffixs r!rz&FindModuleCache.find_modules_recursivels2&&v&> k#7 8I{FD9:  $77??;7L \\   ,&L  Nt||++L9:! UDGG4??[^K_"<6G||--t||T\\=S=SWX=X! LL22%gt||T\\=S=SWX=XY||!!'*LLT\\%D%DLL'' Wm(LM||**<+PQHHTNNN4#>#>v|d?R#ST!ww//5 f:%t#4FFW#>v|d?R#STC! UDr#)NN) rfrrhzFileSystemCache | NonerlzOptions | NonerozStdlibVersions | NonergzBuildSourceSet | Noner)r*)r)r*)rrQr)zModuleSearchResult | None)rrQrr(r) PackageDirs)rr(rrQr) list[str])rrQrrDr)ModuleSearchResult)rIrQr)rD)rrQrrQr)z$OnePackageDir | ModuleNotFoundReason)rrrztuple[str, bool]r)r*)rrQr)rD)rrQrrDr)ztuple[ModuleSearchResult, bool])rIrQr)rb)r+r,r-rRr"rqrrrrrrrrrrr.r#r!rdrds59,0  ! (   2  *    2" /b &>9> <Z22 #2 -24)$[4z7r#rdc|sytjj|jtjd}|j |r|dz }|D]?} t j||r&|r"td|d|dtjyAy#t j$rO}td|d |d |vrd nd zd zdztjtjdYd}~d}~wwxYw)NF/TRACE: Excluding z (matches pattern )r`Tzerror: The exclude z, is an invalid regular expression, because: \z> (Hint: use / as a path separator, even if you're on Windows!)rVz7 For more information on Python's flavor of regex, see:z* https://docs.python.org/3/library/re.htmlr7) rrrelpathreplacerrresearchprintsysstderrerrorexit)rexcludesrhverbose subpath_strres r!rrs ''//'*222663?K}}Ws  yy+.+K=8J7)STU ZZ /, xx  %gY.Z[\Z]^wV  M M??ZZ  HHQKK s:BC>/AC99C>cFtjj|\}}t|D]q\}}tjj ||}|j |r|dz}|j |sN|r!td|d|tjyy)Nr r z (matches .gitignore) in r TF) rrrfind_gitignoresrr match_filerrr)rrhrrrgi_pathgi_spec relative_paths r!rrs WW]]7 #FC+C0 9 == ')C/M   m ,' 6OPWyY  r#ctjj|}||k(rg}n t|}tjj |d}tjj |rAt |5}|j}ddd ||tjdfgzS|S#1swY(xYw#t$r#td|tj|cYSwxYw)Nz .gitignore gitwildmatchzerror: could not parse r )rrrrrrvopen readlinesr from_linesr rrr)r parent_dirparent_gitignores gitignorefliness r!rrs%JS+J7 S,/I ww~~i )_ "KKME " %$h.A.A.RW.X(Y'ZZ Z  " "( % +I;7cjj I$ $ %s=B5C5B>)C-,C-cDtjj|dvS)N)rr)rrr)rs r!rrs 77  D !%D DDr#ctrtjjt |j dD]=}tjjt fdtDr=yy)z;Check that all packages containing id have a __init__ file.rsc3\K|]#}jtd|%ywrurrrwrrhrprefixs r!rzz verify_module..s4     TXi[3I JF S ),FTrrrrrrrr3)rhrrr1rs` `` r!rrsjDwwt$ 288C= !wwt$ .    r#c trtjjd}t |j dD]A}tjjt fdtDs=|dz}C|S)z:Compute the highest level where an __init__ file is found.rrsc3\K|]#}jtd|%ywrur/r0s r!rzz%highest_init_level..s4     TXi[3I JF S r2r6r3)rhrrr1levelrs` `` r!rrswDwwt$ E 288C= !wwt$  .  EE  Lr#crtjd}|sgS|jtjS)NMYPYPATH)rgetenvrpathsep)path_envs r!rr s+yy$H  >>"** %%r#c&tjj|}g}|rtjj|}tjj|d}tjj|dd}tjj|dd}tjj|d}tjj |rtjj |st dj|tjtjdntjj|d }tjj |r|}tjj|d d}tjj|d dd}tjj|d dd}|j||j||j|tjd k7r|jd |sNt d jtj|tjtjd|S)zJReturn default standard library search paths. Guaranteed to be normalised.stdlibstubszmypy-extensionsz mypy-nativeVERSIONSzDerror: --custom-typeshed-dir does not point to a valid typeshed ({})r r7z stubs-autotypeshedwin32z/usr/local/lib/mypyz~Could not resolve typeshed subdirectories. Your mypy install is broken. Python executable is located at {}. Mypy located at {}r6)rrrrrrvrrNrrrr>platform executable) data_dir pyversionrmr typeshed_dirmypy_extensions_dirmypy_native_dir versions_fileautos r!default_lib_pathrKs wwx(HD ggoo.ABww||$7B  ggll+>IZ['',,':G]S \:> ww}}\*"''..2O V]]'ZZ   HHQKww||Hl3 77== Hww||Hj(C  ggll8ZJ[\'',,xWmTKK  KK#$KK  ||w )*   FFLfG    Kr#c|ggfS|tjk(rtj\}}||fSit t j ddi} tjtj|tjdg|tjj\}}||fS#tj$r0}t|j t|j"d}~wt$$rE}|j&Jt j(|j&}t+d|d|g|d}~wwxYw)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. NPYTHONSAFEPATH1 getsearchdirs)envrz!mypy: Invalid python executable 'z': )rrCr rOdictrenvironast literal_eval subprocess check_output__file__PIPErCalledProcessErrorrrstdoutrerrnostrerrorr )python_executablesys_path site_packagesrPerrreasons r!get_search_dirsrbFs5 Bx cnn ,"("6"6"8-. ] ""':bjj!9#3S9 &)&6&6''&I%??&( ' #Hm" ] "",,  #**  #**   99( (([[+F45F4Gs6(ST  s&AB44E+C22 E>AD>>Ec" tjt||j|j}|j rt jdd}|s@t jjt jjt}t jj|}|jt jj|dddg}|so|D]1}|js|j}||vs!|j|3|j rd}nt j"}||vr|j%d|t'} | j)|j&|r| j%d|t+|j,\} } | D] |vsJ | vsDt/ fd | Ds0t jj0s.s'F1<<rww{{ 23F69c3vK|]0}|jtjjz2ywr)rrraltseprgs r!rzz'compute_search_paths..s'&]qq||D277>>4I'J&]riz& is in the MYPYPATH. Please remove it.r zbSee https://mypy.readthedocs.io/en/stable/running_mypy.html#how-mypy-handles-imports for more infor6r%) collectionsdequerKpython_versionrmrrr9rrrWr appendleftrrKr>bazelrinsertrrrbr]rrkrrrrrrreversed) r\rlrD alt_lib_pathrroot_dirrr]rmypypathr^r_rhs @r!compute_search_pathsrvms   g,,'B]B] H $$ 99/6wwrwwx'@AH77??8,BGGLL; ST K  ,Fook)&&s+  , ==C))+C h    q# &{H OOG%%&<(-g.G.GHHm 8### H FXFF3&]T\&]#] TF@A S :ZZ  HHQK  (;/0/8m34Ho  r#cn|xs-ttjjtd}t|d}i}t|d}tjj |sJ||tft |5}|D]}|jddj}|dk(r+|jd\}}|jd} t| d} t| d k\r!| d jrt| d nd } | | f||< d d d |S#1swY|SxYw) 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. r@r=r?#rrV:-r7r6N) rrrrrWrvr$rr parse_versionr) rmrF stdlib_dirr versions_pathr*linerI version_rangeversionsrrs r!rnrns-'],rwwx7PR\*]LlH5J F Z8M 77>>- (X+> x*XX ( m  6 6D::c?1%++-Drz$(JJsO !FM$**3/H' 4K.1(mq.@Xa[EVEVEX hqk*^b )+5F6N 6 6 M 6 Ms BD**D4cr|jjd\}}t|t|fS)Nrs)rrint)rmajorminors r!r{r{s/==?((-LE5 u:s5z !!r#c.t|jdS)zIReturn Python version used for checking whether module supports typeshed.)r8 )rrn)rls r!rrs w%%v ..r#) rrQrrrhrrrDr)rD)rrQrhrrrDr)rD)rrQr)zlist[tuple[str, PathSpec]])rrQr)rD) rhrrrQrrQr1rQr)rD) rhrrrQrrQr1rQr)r)r)r)rDrQrEtuple[int, int]rmrPr)r)r]rPr)ztuple[list[str], list[str]]r) r\rbrlrrDrQrsrPr)r)rmrPr)r0)rrQr)r)rlrr)r)FrR __future__rrSrl functoolsrrrUrenumrrtypingrrrtyping_extensionsr r/pathspecr pathspec.patterns.gitwildmatchr mypyr mypy.errorsr mypy.fscacher mypy.nodesr mypy.optionsr mypy.stubinfor mypy.utilrrrrQrD OnePackageDirlistrrQrr0__annotations__r3r5rrFrTrdrr lru_cacherrrrrrKcacherbrvrnr{rr.r#r!rs #   ))5C$( 0"  6c4i =! "#uU38_huSRUX>W-W'X"XY Y"E?5* ,4,,b3 445  2  0vvr %0?JN B   &E  &00-0DN00f ####N]aU U)0U