ML i UdZddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZmZddlmZmZddlmZddlm Z dd lm!Z!m"Z"m#Z#m$Z$m%Z%dd lm&Z&m'Z'ddl(Z)ddl*Z)ddl+Z)ddl,Z)ddl-Z)ddl.Z)ddl/Z)ddl0Z)ddl1Z)dd l)m2Z2dd l3m4Z4dd l5m6Z6m7Z7ddl8m9Z9ddl:m;Z;mZ>GddZ?e?Z@deAd<e$dZBe%eBe?fZCdeAd<GddZDeDZEdeAd<e;ejejdZHdeAd<dbdZIdcdZJGddeKZLGd d!ZMddd"ZNded#ZOe dfd$ZP dgd%ZQejdhd&ZSePje2j did'ZV djd(ZWejd)ZYdkd*ZZdld+Z[ dmd,Z\ dnd-Z]ePje2jdd. dod/Z_dpd0Z` dqd1Za drd2Zb dsd3Zcdtd4ZdGd5d6e#eBZe du dvd7Zfdwd8ZgePje2j dxd9ZiePje? dyd:ZjePje2j dzd;ZlePje2j d{d<ZnePje2j d|d=ZpePje2j d}d>Zrd~d?Zsdd@ZtddAZu ddBZvddCZwePje2j ddDZyePje2j ddEZ{e|hdFZ}deAdG<e|hdHZ~deAdI<ddJZd~dKZddLZddMZddNZddOZddPZ d ddQZiadReAdS<duddTZddUZ d ddVZddWZddXZGdYdZZe|hd[ZdeAd\<dudd]Zdd^Zdd_Zdd`Zedak(rej(eyy)ziTests for stubs. Verify that various things in stubs are consistent with how things behave at runtime. ) annotationsN) defaultdict)IteratorSet)redirect_stderrredirect_stdout)singledispatch)Path)AnyFinalGenericTypeVarUnion) get_origin is_typeddict)nodes)parse_config_file)UNKNOWNevaluate_expression)Options)FancyFormatterbytes_to_human_readable_repr is_dunderplural_sceZdZdZddZy)MissingzGMarker object for things that are missing (from a stub or the runtime).cy)NMISSINGselfs S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypy/stubtest.py__repr__zMissing.__repr__7sNreturnstr__name__ __module__ __qualname____doc__r#rr$r"rr4s Qr$rr rTztyping_extensions.TypeAlias MaybeMissingceZdZdZddZy)Unrepresentablez5Marker object for unrepresentable parameter defaults.cy)Nrr s r"r#zUnrepresentable.__repr__Ds"r$Nr%r(rr$r"r0r0As ?#r$r0UNREPRESENTABLEF _formatterc R|jddtj|fi|S)z.Wrapper around mypy.util for fancy formatting.colornone) setdefaultr4style)messagekwargss r"_styler<Ns( gv&   G .v ..r$c8t||kDr |d|dz dzS|S)N...)len)r:lengths r" _truncaterBTs) 7|f|!$u,, Nr$c eZdZy)StubtestFailureNr)r*r+rr$r"rDrDZsr$rDcXeZdZddd ddZd dZd dZd dZd d dZy) ErrorN stub_desc runtime_desccp||_dj||_||_||_||_|xst t|d||_|\t|}|tt|d|_ ytj|}t||} t| d|_ y||_ y)aRepresents an error found by stubtest. :param object_path: Location of the object with the error, e.g. ``["module", "Class", "method"]`` :param message: Error message :param stub_object: The mypy node representing the stub :param runtime_object: Actual object obtained from the runtime :param stub_desc: Specialised description for the stub object, should you wish :param runtime_desc: Specialised description for the runtime object, should you wish .typeNdis_async) object_pathjoin object_descr: stub_objectruntime_objectr'getattrrIsafe_inspect_signaturerBreprrJinspectiscoroutinefunctiondescribe_runtime_callable) r!rQr:rTrUrIrJ runtime_sigruntime_is_async descriptions r"__init__zError.__init___s*'88K0 &,"Tc'+v{*S&T  0@K"$-d>.BC$H!#*#>#>~#N 7 N^_ $-k3$?! ,D r$c6t|jtS)z@Whether or not the error is for something missing from the stub.) isinstancerTrr s r"is_missing_stubzError.is_missing_stubs$**G44r$cd|jvS)zOWhether or not the error is for something being (or not being) positional-only.zshould be positionalr:r s r"is_positional_only_relatedz Error.is_positional_only_relateds&55r$cd|jvS)z6Whether or not the error is related to @disjoint_base.z@disjoint_baserdr s r"is_disjoint_base_relatedzError.is_disjoint_base_relateds 4<<//r$c|r't|jddz|jzSd}d}t|jt s|jj }t|jd}||jxsd}d}|r|dt|z }|r ||rdnd |z }d}d}t|jt sC tj|jd } tj"|j}d}|r|dt|z }|r ||rdnd |z }td d d t|jdd|jddt|ddt|j$dzdddt|ddt|j&dzddg } dj)| S#ttt f$rYwxYw#t$rYwxYw)zxReturns a description of the error. :param concise: Whether to return a concise, one-line description T)bold Nrz in file :z at line zerror: redr6ri zStub:)dimblue)r6rqzRuntime:)r<rSr:rarTrlineget_stubrQpathr rUrYgetsourcelinesOSError TypeError SyntaxError getsourcefilerIrJrR) r!concise stub_line stub_file stub_node stub_loc_str runtime_line runtime_fileruntime_loc_stroutputs r"get_descriptionzError.get_descriptions $**6? ?O  #;!G ~V VO 9E 5 4##$ /  LL   >D(D A  ? -  4$$t+6t D wwv9Y 4    s$ "G.GGG G*)G*)rQ list[str]r:r'rTMaybeMissing[nodes.Node]rUMaybeMissing[Any]rI str | NonerJrr&None)r&boolF)r{rr&r')r)r*r+r_rbrergrrr$r"rGrG^sh!%#'%-%-%-. %- * %-%-!%- %-N56 0 8r$rGc ttjd5}tj5t |5t |5tjdtj|}t|dgddddddddddddS#1swY#xYw#1swY'xYw#1swY+xYw#1swYSxYw)Nwignore*)fromlist) openosdevnullwarningscatch_warningsrr simplefilter importlib import_module __import__) module_namerruntimes r"silent_import_modulers bjj# 4'  $ $ & 4(@ 4/RYBZ 4  ! !( +--k:G {cU 3  4 4 44 N 4 4 4 4 4 44 NsQC B; B/9B# B/ B;C#B, (B//B8 4B;;C CCc #Kt|}|et|jddsG|tjvrt tj|nd}t |gdtd|y t|}tj 5tj"d  t%|||gEd{dddy#t$rt$rO}d}t|trd}t |gd |d t|jd ||tYd}~yd}~wwxYw7q#t&$r}t)t+j,|j.dd }|j0j3dd}|dk(s|jdd dk(rt |gdt|jd |||ddt+j4j7zYd}~5d}~wwxYw#1swYyxYww)zTests a given module's stub against introspecting it at runtime. Requires the stub to have been built already, accomplished by a call to ``build_stubs``. :param module_name: The module to test NrLN/Azfailed to find stubsrJrkz7 Maybe install the runtime package or alter PYTHONPATH?zfailed to import.rj: rrr)__main__mypyzencountered unexpected error, zThis is most likely the fault of something very dynamic in your library. It's also possible this is a bug in stubtest. If in doubt, please open an issue at https://github.com/python/mypy rH)rtis_probably_privatesplitsysmodulesrXrGrrKeyboardInterrupt BaseExceptionraModuleNotFoundErrorrMr)rrrverify Exceptionlist tracebackwalk_tb __traceback__ f_globalsget format_excstrip)rstubrJrenote bottom_frame bottom_modules r" test_modulers K D |";#4#4S#9"#=>=HCKK=W4 K 89]bL 5wS_   &{3  "h' dGk]; ; ;   a, -LD M.tfAd1g6F6F5Gr!MtU\    <  1 1!// BCBGJL(2266z2FM *m.A.A#.Fq.IV.S 0a1A1A0B"QCHJ **,2245     sA3H 6 C H G?,D1=D/>D1 H  D,AD'"H 'D,,H /D11 G<:B7G71G?7G<<G??HH c#,Kt|d||yw)zEntry point for comparing a stub to a runtime object. We use single dispatch based on the type of ``stub``. :param stub: The mypy node representing a part of the stub :param runtime: The runtime object corresponding to ``stub`` zis an unknown mypy nodeN)rGrrrQs r"rrs  6g FFsc #6Kd|jvsJ|jjDchc]\}}|js|}}}t||z }t||z }|s|syt |dgzdt t d|d|ycc}}ww)N__all__znames exported from the stub do not correspond to the names exported at runtime. This is probably due to things being missing from the stub or an inaccurate `__all__` in the stubz/Names exported in the stub but not at runtime: z/Names exported at runtime but not in the stub: )rTrUrIrJ)namesitems module_publicsortedrGr)rQrruntime_all_as_setmopublic_names_in_stubnames_in_stub_not_runtimenames_in_runtime_not_stubs r"_verify_exported_namesr's  "" "*.***:*:*<P$!QAPP &';>P'P Q &'9W=X Y  Qs.BBB ABc tj|} t j ||j dS#tttf$rYywxYw#t$rYywxYw)zRetrieve the symbol table for the module (or None on failure). 1) Use inspect to retrieve the source code of the module 2) Use symtable to parse the source (and use what symtable knows for its purposes) Nexec)rY getsourcerwrxrysymtabler))rsources r"_module_symbol_tablerDse""7+  )9)96BB Y , s 9 AAA AAc#Kt|trt|d||yt|tjst|d||yt |drRt |j}d|jvrt|||Ed{nt|dgzdt|nd}|jjDchc]*\}}|jst|r t ||r|,}}}dd}||n,t|Dchc]}t|s |||r|c}}|j||j!t"t%|D]y} | |jvr|j| j&nt} t| t(j*rK| J t-|| t} t1| | || gzEd{{y7Scc}}wcc}w#t.$rYwxYw7$w)Nis not present at runtimezis not a moduleris not present in stubczt||}t|tjryt |}|4 |j |}|j ry|jry |j}t|trt||jk(Sy#t$rYAwxYw#t$rYywxYw)zFHeuristics to determine whether a name originates from another module.FT)rVratypes ModuleTyperlookup is_imported is_assignedKeyErrorr*r'rr)r)rattrobj symbol_tablesymbolobj_mods r"_belongs_to_runtimez,verify_mypyfile.._belongs_to_runtimevsa c5++ ,+A.  # %,,T2%%' %%' 3nnG'3'Gqzz122+       s#B* B. B+*B+. B:9B:)rtypes.ModuleTyperr'r&r)rarrGrrhasattrsetrrrrr module_hiddenrdirupdatedifference_updateIGNORED_MODULE_DUNDERSrnoderMypyFilerVrr) rrrQrrrto_checkrruntime_public_contentsentry stub_entry runtime_entrys r"verify_mypyfilerVs'7#K!''STBU H F  ) \ &q)$GQ/   OO+, 56! L/4 /BTZZ&++ j%.. 1 %%% #GUGH$ H/ G;8H:G;;Hc #lK Gdd|} t|dd}|r)|jst |d||t |yyy#t$rD|js5t|tjst |d||t |Yt$rYwxYw#t$rd}YwxYww)Nc eZdZy)_verify_final..SubClassNrErr$r"SubClassrs r$rzIcannot be subclassed at runtime, but isn't marked with @final in the stubrI __final__FzChas `__final__` attribute, but isn't marked with @final in the stub) rxis_final issubclassenumEnumrGrXrrV)rrrQr runtime_finals r" _verify_finalrs  w &e< T]]  Q  4j   +}+  }}Z%C[t*        sQB4 A B#,B4 A B B4B B4B  B4# B1.B40B11B4PcRtjdk\r4|j|jk7xs|j|jk7S|js |jr4|j|jk7xs|j|jk7S|j}|js|jt z|k(r |t z}|j s|j t z|k(r |t z}|js|j|k(r |t z}||jk7S)znCheck whether two types differ in shape. Mirrors the shape_differs() function in typeobject.c in CPython.)r> )r version_info __basicsize__ __itemsize____weakrefoffset__SIZEOF_PYOBJECT__dictoffset__)t1t2t_sizes r"_shape_differsr s 7"2#3#33Yr"//7YY ??boo##r'7'77]2??boo;] ]!!##(<(<(NRX(X o %F  R%6%6%HF%R o %F##(<(<(F o %F))))r$c^|tury|j}| Jd|dt||S)zqReturn whether a type is a disjoint base at runtime, mirroring CPython's logic in typeobject.c. See PEP 800.TzType z has no base)object__base__r )typbases r"_is_disjoint_basers> f} <>?"   0 &:NL sCCis_alias_targetc # K|jr.|s,t|tst|d||t |yt|trt|d||t |yt|t st|d||t |yt |||Ed{t|||Ed{|jduxr t|}t||||Ed{|jDchc]}|js|}}|jdt|D|jr|j!d|r|j!dt#|D]. } j%d r1 j'd s d |j(j+d  }t- fd |j.Dt0}|J t3||} | t0ur+t ||urt3| d dt |urt0} d vr)| t0ur!|t<urt3| d dt<urt0} t|tr)t| t>j@rtC|drtE|| | gzEd{1y777cc}w#t4$rt7j8||t0} YwxYw#t:$rYwwxYw7Pw)N;is marked as "@type_check_only", but also exists at runtimerrz is not a type)rc3JK|]}t|r|tvs|ywN)rIGNORABLE_CLASS_DUNDERS).0rs r" z"verify_typeinfo..s%(;A(>1LcCcs ###r___new_____c3nK|],}|jvs|jj.ywr%)rr)r'trs r"r(z"verify_typeinfo..s-YqQRQXQXHXqwwu~22Ys55 __objclass__) __setattr__ __delattr__Texclude_special)#is_type_check_onlyrarrGrXrMrrtypeddict_typerrr isidentifierrvarsrdiscardr startswithendswithnamelstripnextmrorrVAttributeErrorrYgetattr_staticrr rWrapperDescriptorTyperr) rrrQr!rr:r mangled_entrystub_to_verify runtime_attrrs @r"verify_typeinforD`s '7+Mt*   '7#K! 0 0 56ug>MYDHHY[bc)))  W&w >   'W W, nd;tG}L"L 3 3G+v% nd;vE"L ~w /<)D)DE->nlK5'r)rQstatic_runtimers r"_static_lookup_runtimerGsb,,[^.names_approx_matchsQ GGCL GGCL||AO!,,q/OSVq[OCFaKOr$_selfstub parameter "z"" differs from runtime parameter "")rVr'rWr'r&r)rvariabler: removeprefixkindrY ParameterPOSITIONAL_ONLY)stub_arg runtime_arg function_namenonspecific_namesrXs r"_verify_arg_nameres 5 +"2"22    ! ! . .t 4 8H8H H!6*,,P 7,,<<.get_nameps?#w001xx#u~~.||((( r$ct|tjryt|tjr-t |j jxs |jStr%) rarYr_rrr'r\rMrnrrs r"get_typez#Signature.__str__..get_typewsI#w001#u~~.3<<,,C0C0CDD r$ct|tjr&|jtjjuSt|t j r|jjStr%) rarYr_rjrkrrr^rsrrs r" has_defaultz&Signature.__str__..has_default~sT#w001{{'*;*;*A*AAA#u~~.xx++-- r$cV|}||rd|ndz|rdzSdzS)Nrrkz = ...r)rarg_typerrrs r"get_descz#Signature.__str__..get_descsH}H &.Rz?B8*3/89 689 r$c$||fSr%r)rVrrs r"z#Signature.__str__..sk!nhWXk=Zr$keyzdef (z, rz**))rr r&r')rr r&r)rr r&r)rrvaluesrRrrr)r!rkw_onlyretrrrrs @@@r"__str__zSignature.__str__os ! ! ! ++-3Z[ tyy&*hh /sXc] /04 ht{{++,4;;3%\^ a(/0x}0 115 x ++, D   s  00s C, &C1 ct}t|j|j}|D]}|jj r|j j|9|jjr$||j|jj<w|jtjk(r||_ |jtjk(r||_t |Sr%)r}r{r: argumentsr^ is_positionalrappendis_namedrr\rARG_STARr ARG_STAR2rr)rstub_sig stub_argsras r" from_funcitemzSignature.from_funcitems.7k#DIIt~~> ! %H}}**, ##H-''):B 1 1 6 67%..0"*%//1!)$$ %r$cZt}|jjD]}|jtj j tj jfvr|jj|`|jtj jk(r||j|j<|jtj jk(r||_|jtj jk(r||_t"|Sr%)r} parametersrr^rYr_r`POSITIONAL_OR_KEYWORDrr KEYWORD_ONLYrr:VAR_POSITIONALr VAR_KEYWORDrr) signaturer\rbs r"from_inspect_signaturez Signature.from_inspect_signatures4=K $//668 %K!!11!!77$&&{3!!W%6%6%C%CC7B "";#3#34!!W%6%6%E%EE%0 "!!W%6%6%B%BB$/ !$$ %r$c tjd}tt}t t j D]}|Jdtj|j}t|D]\}}|jjjdsc|jsW|sU|jjjddk(s-|dk(rQ|jjjdd k(r)||jjjd||jjjd it t j D]}|Jdtj|j}t|D]L\}}|jj}||dhk(rd|}j|gj!||fNdfd }dfd } dfd } t#} t%|D]3} | ddjj} t'j(t'j*| | | dd| | t-d| D}|j.j1r| j2j!||j.j5r$|| j6|jj<|j.t&j8k(r || _ |j.t&j<k(r || _0t@| S)aReturns a Signature from an OverloadedFuncDef. If life were simple, to verify_overloadedfuncdef, we'd just verify_funcitem for each of its items. Unfortunately, life isn't simple and overloads are pretty deceitful. So instead, we try and combine the overload's items into a single signature that is compatible with any lies it might try to tell. Tr1Nz$Failed to resolve decorated overloadr*r+r!rrzFc.td|DS)Nc3&K|] \}}| ywr%r)r'r+indexs r"r(zISignature.from_overloadedfuncdef..get_position..s@Eu@s)max)arg_nameall_argss r" get_positionz6Signature.from_overloadedfuncdef..get_positions@Xh-?@@ @r$cjtjjjd5|Dcgc])\}}|jjxs |j +}}}tj j|Dcgc]}|s| c}cdddScc}}wcc}w#1swYyxYw)NT)rstatestrict_optional_setr\rMrntypeopsmake_simplified_union)rrr+ all_typesr-rs r"rz2Signature.from_overloadedfuncdef..get_types!!55d; WKST\K]AGaCLL%%<)<)<< ||99i:UST1:UV  W W;V  W Ws. B).B" B)B$ B$ B) B))B2cJ|Dchc]\}}|j}}}tj|vrtjStj|vrtjSt |t j kxs&tj |vxstj|v}tj |vxstj|v}|r"|rtj StjS|rtjStjScc}}wr%) r^rrrr@rARG_OPT ARG_NAMED_OPTARG_POS ARG_NAMED)rrr+kindsis_optis_posrrs r"get_kindz2Signature.from_overloadedfuncdef..get_kinds,4X,>?&#qSXX?E?~~&~~%%'& HX&'#djj/90==E)0&&%/  ]]e+Eu}}/EF(.u}}GE4G4GG$*5== ? ?!@sDrc3:K|]\}}|jywr%)pos_only)r'rr+s r"r(z3Signature.from_overloadedfuncdef..sKfc1S\\Ks)rnrrr^r)rr'r&int)rr'r&zmypy.types.ProperType)rr'r&z nodes.ArgKind)!rr:rrmap _resolve_funcitem_from_decoratorrr{r enumerater\r8rraddr8rr}rrrVarallr^rrrrrrrrr)rassume_positional_onlyis_arg_pos_onlyfuncrTrrr:rrrsigrexample_arg_namers` @r"from_overloadedfuncdefz Signature.from_overloadedfuncdefs"+499d!K7B37G8$**E BD# K%K K#"499dnn=D'o B sLL%%006||-||((..s3v= s||'8'8'>'>s'Cu'L#CLL$5$56::4@#CLL$5$56::5A B BAC8$**E CD# K%K K#"499dnn=D'o C s ||(("4(TF2w? $ h'K8JKK Cxx%%'s#""$03 3<<,,-U^^+  U__, $$' %( r$Nr&rr%)rnodes.FuncItemr&Signature[nodes.Argument])rinspect.Signaturer&Signature[inspect.Parameter])rnodes.OverloadedFuncDefr&r) r)r*r+r_rrOrrrrr$r"r}r}hsK$ 'R $__r$r}c#Kt|j|jD]\}}t|||Ed{t||Ed{|jt j jk(r|js|jjjds|jjjddk7r^|jjjddk7r6t|ds)d|jjd|jd |jt j jk7s7|js'|jjjdsj|jjdr|jjjddk7s|jjjddk7st|drd|jjd t|jt|jkDr|jk|jt|jdD]x}|jj|j vr8d |jjd }|j"|d z }n|r|dz }|]d|jjdz|jd|jjjd nt|jt|jkrp|jt|jdD]K}|j|j vrt%|r'd|jd :d|jdMt|jt|jks |jr|j(|jd|jjd |j2|j&d|jjjd t't)|j t)|j zD]I}|j ||j |}}t|||Ed{t||Ed{K|j"7t)|j j+t)|j st't)|j t)|j z D]}||jDchc]}|jc}vrF||jt|jdDchc]}|jc}vsfd|dod |d }|r|dz }|t't)|j t)|j z D]}||jDchc]}|jjc}vr\|jG||jt|jdDchc]}|jjc}vrd|dt%|j |rd|d |j"|j"|jDchc]}|jj}}t)|j j+t)|j |zsd|j"jd |j"4|j"'d|j"jjd yyy7y7h77cc}wcc}wcc}wcc}wcc}ww)Nr*r+r!rzTr1rZz," should be positional-only (add "/", e.g. "z, /")z." should be positional or keyword (remove "/")z!runtime does not have parameter "r[z7. Maybe you forgot to make it keyword-only in the stub?z>. You may need to write stubs for __new__ instead of __init__.z" is not keyword-onlyz'runtime does not have *args parameter "zstub does not have parameter "rgz$stub does not have *args parameter "z'stub does not have **kwargs parameter "z*runtime does not have **kwargs parameter ")ziprrerxr^rYr_r`rr\r:r8rrr@rrr_is_private_parameterrrissubset) rrrcwarn_runtime_is_object_initrarbmsgrstub_pos_namess r"_verify_signaturers"%TXXw{{!;+#Hk=III,X{CCC    1 1 A A A%%%%**55d;!!&&,,S1V;!!&&,,S1U:mTB#8#4#4#9#9":;##.#3#3"4E;     1 1 A A A""h&7&7&<&<&G&G&M$$//5!!&&,,S1V;!!&&,,S1U:mTB#8#4#4#9#9":; /: 488}s7;;'' >> ! HHS%5%78 [$$))?=h>O>O>T>T=UUVWC}}0XX4__I,X->->-C-C,DDYZZ [{{&? @T@T@Y@Y?ZZ[\\ TXXW[[) )";;s488}7 TKt{{2,[9:;;K;K:LANN+K,<,<+==RSS  T 488}GKK((GNN,B ;; 7>>#=89L9L8MQO O ;; "w~~'=;DKK $((Ch8$$))C C&488CPWP[P[L\L^C_`xH--22``(-BCC()<=6se1== > zzgmm7BFJX(++00JJ7>>"++C ,<~,MN;GMM _ F_(D5_^9_1^<2B_^?)_=__A"_7_ 5_ _&_+!_ 0_=_B_6_9_<_?_c|jjdxrD|jjd xr&|jtjj uS)Nr+r*)r:r8rjrYr_rkrs r"rrsP C  7##D) ) 7 KKw0066 6r$c#ZKt|trt|d||yt|st|d||t |syt |}t|t jrCt||D]}t||||t|||D]}t||||t||||D]}t|d|z||t|}tj|}|rCtj|}tj!|} t#||} t%|} nd\} } |r|j&st|d||| | |syt) |j*|t,j.uD]}t|d|z||| yw) Nris not a functionis inconsistent, rO)NNz:is an "async def" function at runtime, but not in the stubrHrcrr)rarrGis_probably_a_functioncallablerGrFuncDef_verify_abstract_status_verify_final_methodrRrWrYrZr}rrr[r' is_coroutinerr:r r_) rrrQrF error_textr:rruntime_is_coroutinerr\runtime_sig_descrIs r"verify_funcitemrs'7#K!gNNO'w/I"66w?**4066yA 4YI]^M &0#) D$5$5  H  )    $ii$+v$>      ' )  )    sF)F+c#>K|turyt|d||yw)Nr)rrGrs r"verify_missingrs%'  5tW EEsc#&Kt|trt|dkrt|d||y|jr3t |r(|j s |jst|d||t||j}||jt||jsd}t|tjrt|j}|t||jrd}tjj!|j}t|tjj"r2|jj$tjj&vrd}|rt|d|||yyyyyw)Nr+is read-only at runtime but not in the stubrhTFz#variable differs from runtime type )rarr@rGis_initialized_in_classis_read_only_propertyis_settable_property is_propertyrmrMrqrrvaluerrget_proper_typeInstancerELLIPSIS_TYPE_NAMES)rrrQrt should_error proper_types r" verify_varrs\'7# { q  %@$P P $$ !' *  & &d.>.>K!NPTV]^^1' RL II !!, :  gtyy )9'--HL',=lDII,V$ **44TYY?K; (;(;<$$--1O1OO$ B<.QSWY`  #; " !sFFc #bKt|trt|d||y|jrt |rt|d||yt |st|d||t |sy|jd}t|tjr7|jr+t|j|D]}t||||t|}t||||D]}t|d|z||t|}|syt j#|}t j%|} t'|| |j(|t*j,uD]F}d|vr|dz }t|d|z||t/|j0d |zd t/|z Hyw) Nrrrrrrzhas a default value of typezc. This is often caused by overloads failing to account for explicitly passing in the default value.z Inferred signature: def rH)rarrGrrrrrr Decorator is_overloadrrrGrRrWr}rrrr:r r_r'rM) rrrQ first_partrrFr:rrr\s r"verify_overloadedfuncdefrs '7#K!gNNO 'w/I //5H229=K$ii$+v$>   )G 3 ( G  ' )  499~+A()LL#i.0    sF-F/c#Kt|tr!|jdk(ryt|d||yt|tst|d||yyw)N_NTrzis not a TypeVar)rarr:rGrrs r"verify_typevarexprr\s\'7# 99  K!.wsN! ANszis not a ParamSpec)rarrGrVtypingtyping_extensionstuple)rrrQmaybe_paramspec_typesparamspec_typess r"verify_paramspecexprrls'7#K!U>U#V \`   ! lI 6 SS/ J J Js8AE2E+AE2E.8E2E0BE2.E20E2c#K|jtjk(}t|dd}|r|s|jrdnd}d|dyyyw)N__isabstractmethod__Frmethodzis inconsistent, runtime z is abstract but stub is not)abstract_statusr IS_ABSTRACTrVr)rr stub_abstractruntime_abstract item_types r"rrsX((E,=,==Mw(>F "&"2"2J ))4PQQ!.sA A c#vK|jryt|dds|turt|ddrdyyyw)NrFz8is decorated with @final at runtime, but not in the stub)rrVr)rrrFs r"rrs@ }}w U+g%'.+u*UHH+V%s79cttjrSjjry dfd }j}j D]}|||}|y|}|S)zReturns a FuncItem that corresponds to the output of the decorator. Returns None if we can't figure out what that would be. For convenience, this function also accepts FuncItems. Ncpt|tjrVt|jtjr2|jj t jjvr|St|tjsy|j sy|j dvsr|j t jjvsL|j t jjvs&|j t jjvr|S|j dk(r|jdjjdvr.apply_decorator_to_funcitemsY y%.. 19++U]];  ))TZZ-M-MMK)U]]3!!   "Q Q!!TZZ%>%>>!!TZZ%H%HH!!TZZ%E%EEK   !7 7~~a ))..6OO%6t~~a7H7Q7Q7V7V6YZ,,) ))D/CMM!"-CMJr$)r3znodes.Expressionrrr&nodes.FuncItem | None)rarFuncItemrroriginal_decorators)r4r5rr3resulting_funcs` r"rrs #u~~&  xx"#"+9" "H88D,, 4YE  !  Kr$c #K|jjr,t|tst |d||t |yt|trt |d||y|jj rMt||D]}t ||||t|j|D]}t ||||yt|}|t|||Ed{yy7w)Nr#rr) rr3rarrGrXrrrrr)rrrQr:rs r"verify_decoratorr;s yy##'7+Mt*   '7#K!MatchPatternr rLz_?Tr r> zis not a Union__mro__rzis not a subclass of tuplez is not a type alias for Callablezis not a recognised type alias)rrrtargetrarrGrrrMr+r>rVrr'r= fullmatchescaperrD UnionTyperrr TupleTyper r collectionsabcCallableAnyType) rrrQ stub_targetrIruntime_origin stub_origin runtime_nameruntime_moduleruntime_fullnames r"verify_typealiasrRs**,,T[[9K!+/I'7#K! >94T]  +tzz667 !9!9 9?wZc  +tzz112  =tWXa bbW H">:wGL H" cs8B4K7 J$BKKEK$K>KKK>r,__file__r)__path____spec__ __author__ __cached__ __loader__ __getattr__ __package__ __version__ __annotate__ __builtins__ __copyright____annotations____warningregistry__r>.__cmp____div__r,__args__r__hash__rr __origin__ __reduce__rY __nonzero__r/ __unicode__ __weakref__r\ __ctype_be__ __ctype_le__ __getstate__ __setstate__ __reduce_ex__ __slotnames____getnewargs____new_member____orig_bases____parameters____pyx_vtable__r___firstlineno____getinitargs____subclasshook____annotate_func____classdictcell____instancecheck____subclasscheck____protocol_attrs____text_signature____abstractmethods____dataclass_fields____dataclass_params____vectorcalloffset____annotations_cache____static_attributes____ctypes_from_outparam____non_callable_proto_members____callable_proto_members_only__r&c@|jdxr t| S)Nr+)r8rr:s r"rrs ??3  7 $$77r$c,t|tjtjtjtj fxsKt j|xr t|xs't|tjxr t|Sr%) rar FunctionTypeBuiltinFunctionType MethodTypeBuiltinMethodTyperYismethoddescriptorrMethodWrapperTypers r"rrs} ""))  ''   P  & &w / EHW4E P w 7 7 8 NXg=N r$cBt|txr|jduSr%)rarfsetrs r"rrs gx ( AW\\T-AAr$ct|dr[|jdk(rKt|dr>|jdk(r.t|dr!t|jdr |jj t j |j}tj j}|jrmtt|jj}|jtj jk(rtj j}|jt j d|g|jjSt|dr|jdk(rt|dr|jd k(rt|d rt|j drs|j j\d }t|j drNt|j j"dr.|j j"j|j urd }|s t j |j }tj j}|jrmtt|jj}|jtj jk(rtj j}|jt j d |g|jjS t j |S#t$rYwxYw#t$rY2wxYw#t$$rt|drd|jvr|jjdd}t j&tj(||}t+|tj(sJ|jjDcgc](}|j,dur|jt.n|*ncc}w}}|j|cYSwxYw#t$rYywxYw)Nr)r_r}z($self, /, *args, **kwargs)r.r!)rr)z($type, *args, **kwargs)rKFTrzr2r?.)rj)rr)r}r.rYrr_rrr<iterrr^r`replacerrKr_ ValueError_signature_fromstrr}rarjr3)rsparameter_kindfirst_parameterhas_initr parameter new_paramss r"rWrWs$    * G1 2  & &*G G G^ , G((*> ?  3 3 ? !!'"6"67A5<5F5F5\5\N||"&tALL,?,?,A'B"C"''7+<+<+L+LL%,%6%6%F%FN99#--fnE^ H[H[H]^  $    ) G1 2  & &*D D GZ ( G$$&: ;    / / ; G$$j 1((11>B  ))66':J:JJH %%g&6&67!(!2!2!H!H<<&*4 0C0C0E+F&GO&++w/@/@/P/PP)0):):)J)Jyy ' 1 1% Ha1<| j&t(j*j@k(r!|j%tjB| j&t(j*jDk(r!|j%tjF!tHn2||g}tjBtjFg}ddg} tjjK||| ||dSd} |rtjjM|}t|tjjJr0t|jNtjjPrd} t|tjjRr0t|jTtjjPrd} t|tVr| sd d} tY|jZ|j\}t|tjrbd}tj^ja|| }tjbje|rtjfji|}|StYtW|jZtW|j\}|yt|tjjr |jVSt|tjsyt|tlrv|Dcgc] }to|}}|Dcgc] }||n|}}tjj||g}tjjq||Stjj||jrDcgc] }| c}}t|ttjvr't|j.txr |j.}n.anytypeas'zz!!$**"6"6"B"BCCr$builtinsfunctionT)rfallbackis_ellipsis_argsFc|jdd}t|d|d}t|tjsJt j jt j jj}t j j||gt|jjzS)NrLrm)maxsplitr)rsplitrrarTypeInforrrKr special_formrr@defn type_vars)r:partsrany_types r" _named_typez3get_mypy_type_of_runtime_value.._named_typesKKaK0E)%(E!H=DdENN3 33zz))$***>*>*K*KLH::&&thZ#dii>Q>Q:R-RS Sr$)rr)r&zmypy.types.AnyType)r:r'r&zmypy.types.Instance)BrrNoneTyperarrrrrrtrrrrrrWrrrr^rYr_r`r:rjrkrrrrrrrrrrrrrrroTypeTypeitemrMrr*r)rtype_object_type checkexpris_type_type_context erasetypeerase_typevarsrr rmrGrrrr'bytesrrrr)rrirr type_inforr arg_types arg_kinds arg_namesr no_defaultskip_type_object_typerresultvoptional_itemsirr+rs r"rmrmSszz""$$'8$D   U668H8H%JaJabJ'###NN:.33 )U^^444::&&y79+>*73 III ++224 )  +  HH(9(9(I(IIDsxx![[G,=,=,C,CC 88w00@@@$$jU]]emmTXX!2!2!H!HH$$jU]]emmTXX!2!2!?!??$$ U__H[H[\XX!2!2!A!AA$$U^^4XX!2!2!>!>>$$U__5((# )&!GI.I9It Izz&&   Y! '  "zz11,? lDJJ$;$; <,//1G1GH(,% lDJJ$7$7 8,++TZZ-C-CD(,%'4 )> T+7+=+=w?O?OP i 0-1F\\229kJF~~22<@66v>M'tG}'?'?gAWAWXI)UYY'~~ i 0'5!ELM8;MM>LMq}!')3MM::&&y79+>zz##E844zz""9)BUBU.VQwy.VWH'499%*W\\3*G  GU #,W5 GdC- . :: ! ! ! AA#NM/Ws#[0;[5=[: zdict[str, nodes.MypyFile] _all_stubsc & tjj}tjj g||}tjj |d|}g g}|D]} j ||sS|j|}t|ts8|j tjj||di|j|} |j|  j fd| D t|} j fdtj| j | j"dzD|ra tjj||} | j(r't-dd j/| j(z| j0a S#t$$rt&$rYrwxYw#tj(j*$r} t-d| | d} ~ wwxYw) aUses mypy to construct stub objects for the given modules. This sets global state that ``get_stub`` can access. Returns all modules we might want to check. If ``find_submodules`` is False, this is equal to ``modules``. :param modules: List of modules to build stubs for. :param options: Mypy options for finding and building stubs. :param find_submodules: Whether to attempt to find submodules of the given modules as well. N)fscacheoptionsc3TK|]}|jvs|j!ywr%r)r'r all_moduless r"r(zbuild_stubs..s!^A!((R]B]qxx^s((c3RK|]}|jvr|j ywr%r)r'rrs r"r(zbuild_stubs..s)#vv[0FF#s$'rL)sourcesrzfailed mypy compile: zmypy build errors: rp)rbuilddefault_data_dir modulefindercompute_search_pathsFindModuleCacher find_modulerar' BuildSourcefind_modules_recursiveextendrpkgutil walk_packagesrTr)rrerrors CompileErrorrDrRfilesr)rrfind_submodulesdata_dir search_pathfind_module_cacherr module_path found_sourcesrresrrs @r" build_stubsrszz**,H##88WhOK))99T7:KG6"+77?Kk3/ NN4,,88fdS T-DDVLM NN= )   ^^ ^ .v6""#$2273C3CWEUEUX[E[\#!4 G**""7G"DC ::!"8499SZZ;P"PQ QYY !%     {{'' G!$:1#">?Q F Gs+AG$!GGGH<H  Hc,tj|S)z?Returns a stub object for the given module, if we've built one.)rrrs r"rtrts >>& !!r$ctjj|tjddd fd }|r t |}n*t tj jdz }|dz }t}|jdD]r}|jdk(r |j}d j|j|jdd |jfz}||sb|j|t|S) zJReturns a list of stdlib modules in typeshed (for current Python version).NrrcJ|jd}tt|ddD]6}dj|d|}|vs|\}}|k\xr |duxs|kcSy)NrLrrF)rranger@rR)rrrcurrent_moduleminvermaxverstdlib_py_versionsrs r"exists_in_versionz6get_typeshed_stdlib_modules..exists_in_version&s''' S!s5z1b) ]A XXeBQi0N!33!3N!C#v-\6T>3[\U[E[\  ] r$typeshedstdlibz*.pyir_rLr)rr'r&r)rrload_stdlib_py_versionsrrr rrrrglobstemparentrR relative_torr) custom_typeshed_dirrr typeshed_dir stdlib_dirrrurrs ` @r"get_typeshed_stdlib_modulesrs**BBCVW''!, /0 DJJ779:ZG (JG  )  99 ";;D$**:6<rr9r8rr) all_stdlib_modulesmodules_by_finderrfinder module_groupimportable_stdlib_modulesrr runtime_pathrO submodulesubmodule_names r"get_importable_stdlib_modulesr@s 7" 44 !9!9:S^_bSc%%' ?A!//9+>+>+I+IJ!!//266qvv> ?%6$;$;$= 8 FLtFKK'8'>'>>w',6")),7 8+.%)/> 1 1  7*;7G & ) )+ 6 "++L"++L!..|\C=OP >I&^^N&&{3~7P7P%8 >$^4*--n=; >%/>b %$W      0% !  s6) G G* G* GG G'&G'*G?>G?c#Kdd}t|5}|D]}||}|s| dddy#1swYyxYww)Nc |d|jdjS#t$r|jcYSwxYw)N#)rrr)rs r"strip_commentsz-get_allowlist_entries..strip_commentss@ ^qwws|$**, , 779  s!$AA)rr'r&r')r)allowlist_filerfrsrs r"get_allowlist_entriesrsL n  D"4(E  s?33 ?<?ceZdZUded<ded<ded<ded<ded<ded<ded <ded <d ed <d ed <ded<ded<ded<ded<y) _Argumentsrrrr{ignore_missing_stubignore_positional_onlyignore_disjoint_bases allowlistgenerate_allowlistignore_unused_allowlistrmypy_config_filercheck_typeshedr'versionshow_tracebackpdbN)r)r*r+r_rr$r"rrsS  M  !!  ## L Ir$r>thisr antigravity _ios_supportr c|jDcic]}t|D]}|d}}}|Dcic]}|tj|}}t }|j }|j rY|j rttddddyt|j}t} t|| ztz }|sttddddyt} d| _|j| _ | jr.t j"j%| j| _|j(| _|| _|j.| _|j0| _| j*r9dd } t3| | | j*t4j6t4j8dd } dd } | j;| | j=| | | j? tA|| |j }d}d}|D]}tE|D]}|jFr|jIr |jJr|jMr=|jNr|jQrZ|jR|vrd||jR<xd}|D])}||jU|jRs"d||<d}n|rd}|jVr|jY|jRt[|j]|j^|dz }|j`s7|D]2}||r ||jUdrd}|dz }td|4|jVrt|D] }t|d}|S|j^sr|rAttd|dtc|dte|dtc|d dd|Sttdte|dtc|dd|Scc}}wcc}w#tB$r%}ttdddd|Yd}~yd}~wwxYw)z.This is stubtest! It's time to test the stubs!Ferror:rnTroz7cannot pass both --check-typeshed and a list of modulesrmzno modules to checkcyr%rrr$r"set_strict_flagsz$test_stubs..set_strict_flagss r$c^ttddd|tjdy)Nr.rnTrorm)printr<rexitrs r"error_callbackz"test_stubs..error_callbacks  fXU6<  r$c4ttddd|y)Nzwarning:yellowTro)r2r<r4s r"warning_callbackz$test_stubs..warning_callbacks fZxd;SAr$)r5)r5r8)rznot checking stubs due to Nr)r{rkznote: unused allowlist entry zFound z errorz (checked z modulerzSuccess: no issues found in greenr)rr'r&ztyping.NoReturn)rr'r&r)3r"rr=compilerrr&r2r<rrrrr r incrementalrruabspathabs_custom_typeshed_dirr% config_fileuse_builtins_fixturesr(r)rrstdoutstderrprocess_error_codesprocess_incomplete_featuresprocess_strict_bytesrrDrrrbr rer!rgrSrDr#r safe_printrr{r$rr@)rTr?rrr"allowlist_regexesgenerated_allowlistrtypeshed_modulesruntime_modulesrr0r5r8stubtest_failure exit_code error_countrerroris_allowlistedrrs r" test_stubsrOs~ #nn *>:  u  I @IIe 5 11II%llG  << xu48I 6t7O7OP79*_<@WWX  fXU68MNiGG"&":":G""*,''//':U:U*V'//G$9G!!00G((GK  '#3W5H5H#**VYV`V`aB ~> ''%8H(   "gwDDWDW@WXIK ( E''E,A,A,C**u/O/O/Q))e.L.L.N  I-/3 %++,"N $Q'11%2C2CD#'IaL%)N   I&&#''(9(9: u,,T\\,B C 1 K5 <  ' ' ;AQ<(9!(<(F(Fr(J q 5aS9:  ; +, A !H  ( '\\  [M0E/F Wghw6G5HK  "  23w<.QXHYGZ[!  E Jj  85t 4()9(: ;  s"P P&?P++ Q4QQctjj}|$|j|dj |d}t |y)zBPrint a text replacing chars not representable in stdout encoding.Nr)r)rr@encodingencodedecoder2)text out_encodings r"rErE9 sE ::&&L{{< {:AA,W`Aa $Kr$ctjd}|jddd|jddd |jd dd |jd dd |jddd |jddddgd|jdddd |jdddd |jddd|jd d!d"|jd#dd$ |jd%d&d'tjj z(|jd)dd* |jd+d,dd- |j |t.S)/Nz8Compares stubs to objects introspected from the runtime.)r^rrzModules to test)nargshelpz --concise store_truez8Makes stubtest's output more concise, one line per error)actionrXz--ignore-missing-stubzAIgnore errors for stub missing things that are present at runtimez--ignore-positional-onlyzLIgnore errors for whether an argument should or shouldn't be positional-onlyz--ignore-disjoint-basesz1Disable checks for PEP 800 @disjoint_base classesz --allowlistz --whitelistrFILEzUse file as an allowlist. Can be passed multiple times to combine multiple allowlists. Allowlists can be created with --generate-allowlist. Allowlists support regular expressions.)rZmetavarrjrXz--generate-allowlistz--generate-whitelistz:Print an allowlist (to stdout) to be used with --allowlistz--ignore-unused-allowlistz--ignore-unused-whitelistzIgnore unused allowlist entriesz--mypy-config-filezFUse specified mypy config file to determine mypy plugins and mypy path)r\rXz--custom-typeshed-dirDIRzUse the custom typeshed in DIRz--check-typeshedz$Check all stdlib modules in typeshedz --versionr'z %(prog)s )rZr'z--pdbzInvoke pdb on fatal errorz--show-tracebackz--tbzShow traceback on fatal error) namespace)argparseArgumentParser add_argumentrr'r[ parse_argsr)rTparsers r" parse_optionsrdF s  $ $NF  3DE  G   P  " [  ! @   +   I   ## .   V  5U <6\ I{T\\=U=U/U  ;VW F<>]   TZ\  ::r$ctjjdtt t j ddS)Nstubtestrm)rutilcheck_python_versionrOrdrargvrr$r"mainrj s.II"":. mCHHQRL1 22r$r)r:r'r;r r&r')r:r'rArr&r')rr'r&r)rr'r&Iterator[Error])rrrrrQrr&rk)rQrrnodes.MypyFilerset[str]r&rk)rrr&zsymtable.SymbolTable | None)rrlrzMaybeMissing[types.ModuleType]rQrr&rk)rnodes.TypeInfor type[Any]rQrr&rk)r type[object]rrpr&r)r rpr&r)rrnrrprQrr&rk) rrnrrorQrrrr&rk) rrnrzMaybeMissing[type[Any]]rQrr!rr&rk)rQrr&r) rznodes.FuncBaserr rFrrQrr& Iterator[str])ranodes.Argumentrbinspect.Parameterrcr'r&rq)rarrrbrsr&rq)r:r'rTlist[nodes.Argument]r&rtr) rrrrrcr'rrr&rq)rrsr&r)rrrrrQrr&rk)rrrrrQrr&rk)rz nodes.VarrrrQrr&rk)rrrrrQrr&rk)rznodes.TypeVarExprrrrQrr&rk)rznodes.ParamSpecExprrrrQrr&rk)rr r&r)rnodes.Decoratorrr r&rq)r nodes.FuncDefrr r&rq)rrvrr rFrr&rq)r4znodes.OverloadPartr&r6)rrurrrQrr&rk)rznodes.TypeAliasrrrQrr&rk)r:r'r&r)rr r&r)rr r&zinspect.Signature | None)rrrPrr&r')rmypy.types.Typerrwr&r)rr'rr'r&zmypy.nodes.SymbolNode | Noner%)rr rimypy.types.Type | Noner&rx)rrrrrrr&r)rr'r&znodes.MypyFile | None)rrrztuple[int, int] | Noner&rm)r&rm)rr'r&rq)rTrr?rr&r)rTr'r&r)rTrr&r)r&r)r, __future__rr_collections.abcrHr2rrrimportlib.machineryrYrrr=structrrrrr r rrrr AbstractSet contextlibrrr pathlibr r r r rrrr mypy.buildrmypy.checkexprmypy.checkmembermypy.erasetypemypy.modulefinder mypy.nodes mypy.state mypy.types mypy.versionrmypy.config_parserr mypy.evalexprrr mypy.optionsr mypy.utilrrrrrrr_r-r.r0r3r@rAr4r<rBrrDrGrrrr lru_cacherregisterrrrcalcsizerr rrrrrDrGrRrerxr{r}rrr7rrrrOverloadedFuncDefr TypeVarExprr ParamSpecExprrrrrrrrr; TypeAliasrR frozensetrr&rrrrWr[rqrrmrrrtrrrrr rOrErdrjr)r3rr$r"rsJ #     #87$66606 WW CL,1!W*,= )=##)**#3::szz5A EA/   i nnl 5p G " G-> GMV G G G"0FN: " ]L ]L#A]LPY]L]L!]L@$ $ #,$ ;D$ $ N"&//#&*,%5 5#/5>G55p# ##,#;D#_c##L " eS eS $eSeS  eS  eS!eSP : :#&:8I:Xa:::""+<"MP""JDD+<DDNt tv). uW #uW )uWuW"& uW  uWp ? ? #4? CL? ? !? DF F-FG(((V(()A !A ,=A LUA A *A H""#   &7 FO  $ $$%   (9 HQ  &  T:RI I"%I7HII5p!6 6$56DM66"6>!Dc Dc$5DcDMDcDc"DcX!*!."+9;";|8  B_D<5.&:>~B ~B 6~B~BL)+ %*:z" MQ#3I DJ%Z $"++^!__FR E;P3  z CHHTVr$