ML i%7bddlmZddlmZddlmZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZmZmZddl m!Z!m"Z"m#Z#m$Z$ddl%m&Z&dd l'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3dd l4m5Z5dd l6m7Z7dd l8m9Z9dd Z:ddZ;ddZ d! d"dZ?GddeZ@ d! d#dZA d$ d%dZBd&dZC d'dZD d( d)dZEd*dZFy)+) annotations) NamedTuple)map_actuals_to_formals) TypeFixer)ARG_POSMDEFSYMBOL_FUNCBASE_TYPESArgumentBlockCallExprClassDef Decorator ExpressionFuncDefJsonDictNameExprNodeOverloadedFuncDefPassStmtRefExprSymbolTableNodeTypeInfoVar)CheckerPluginInterfaceClassDefContextSemanticAnalyzerPluginInterface)ALLOW_INCOMPATIBLE_OVERRIDE parse_boolrequire_bool_literal_argumentset_callable_name)try_getting_str_literals) AnyType CallableTypeInstance LiteralTypeNoneType OverloadedType TypeOfAnyTypeType TypeVarTypedeserialize_typeget_proper_type)is_overlapping_none) fill_typevars)get_unique_redefinition_namecjt|jtrt||j||S|S)zgReturn the bool argument for the decorator. This handles both @decorator(...) and @decorator. ) isinstancereasonr _get_bool_argument)ctxnamedefaults Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypy/plugins/common.py_get_decorator_bool_argumentr97s, #**h'!#szz4AAcRt||}|rt|j|||S|S)z]Return the boolean value for an argument to a call or the default if it's not found. ) _get_argumentrapi)r5exprr6r7 attr_values r8r4r4Bs-tT*J,SWWj$PP Nr:c4t|}|sy|j|}|sy|jsJtt |j |j D]<\}\}}|j|s||jk(r|cS||jk(s:|cSy)z0Return the expression for the specific argument.N)_get_callee_typeargument_by_namer6 enumeratezip arg_namesargspos)callr6 callee_typeargumenti attr_namer?s r8r<r<Ls#4(K ++D1H  ===&/DNNDII0N&O" "Iz << #I!x||:K   %   r:c  |jddD]}d}t|j|j|j|jd}t |D]} j |t fdtt|jDrd}t|j|j|D]\ }}|jr|sd}n|s |Dcgc]}|j|}}t  t d|D} t tr| rld}n| rHt! s=t t"r j$j&dk(st t(sd}nFt t*st j,t.st fd |Drd}n|s|cS|jdScc}w) aTPerform limited lookup of a matching overload item. Full overload resolution is only supported during type checking, but plugins sometimes need to resolve overloads. This can be used in some such use cases. Resolve overloads based on these things only: * Match using argument kinds and names * If formal argument has type None, only accept the "None" expression in the callee * If formal argument has type Literal[True] or Literal[False], only accept the relevant bool literal Return the first matching overload item, or the last one if nothing matches. NTc4ttjSN)r"r) special_form)rKs r8z5find_shallow_matching_overload_item..{sgi445r:c3&K|]}|v ywrP).0rKmatched_actualss r8 z6find_shallow_matching_overload_item..sGAq'GsFc3^K|]%}t|txr|jdk('yw)NoneN)r2rr6)rUargs r8rWz6find_shallow_matching_overload_item..s)`TWz#x8OSXX=OO`s+-zbuiltins.objectc3NK|]}t|jk(ywrP)rvalue)rUrZarg_types r8rWz6find_shallow_matching_overload_item..sQSz#(..@Qs"%)itemsr arg_kindsrEsetupdateanyrangelenrFrD arg_types is_requiredr-r2r&r.r$typefullnamer"r%r\bool) overloadrHitemokmappedactualskindrKrFarg_noner]rVs @@r8#find_shallow_matching_overload_itemrqess#. ' NN NN NN NN 5  % ,G  " "7 + , Gs499~1FG GB'*4>>4>>6'R  #HdG!'.56 ! 66*84`[_``h1#"/9"8X6$MM226GG&x9B+6:hnnVZ;[QDQQ"7 8 K].^ >>" 17s)GcV|j}t|tr |j}t|tr |j }t|t tfrO|jrCt|j}t|tr t||St|tr|Sy)z@Return the type of the callee, regardless of its syntactic form.N) calleer2rnoderfuncrr rgr-r'rqr#)rH callee_nodecallee_node_types r8rArAs ${{K+w'!&& +y)!&& +%:;<AQAQ*;+;+;< & 367GN N (, 7# # r:Nc Tt|j|j||||||| y)zZ Adds a new method to a class. Deprecated, use add_method_to_class() instead. )r6rF return_type self_typetvar_defis_classmethodis_staticmethodN)add_method_to_classr=cls)r5r6rFryrzr{r|r}s r8 add_methodrs/    %' r:cBeZdZUdZded<ded<dZded<dZd ed <y) MethodSpecz=Represents a method signature to be added, except for `name`.list[Argument]rFr(ryN Type | Nonerzzlist[TypeVarType] | None tvar_defs)__name__ __module__ __qualname____doc____annotations__rzrrTr:r8rrs&G !I{!*.I'.r:rc Bt|||t|ts|g}t||j|t ||||||\} } | |jj |<|jjjjj| | S)z(Adds a new method to a class definition.)rFryrzr)r|r}) _prepare_class_namespacer2list_add_method_by_specinfornamesdefndefsbodyappend) r=rr6rFryrzr{r|r}rusyms r8r~r~sS$'Jx$>:#   +V^_%' ID#CHHNN4HHMM""4( Kr:c t|dk\sJdt||g}|D]}t||j||||\}} t |t rPt |j|j} | j|jd|_ t|g| } n|} d| _ |j| t|} |j| _|| _|| _t%t&| } d| _| |jj*|<|jj,j.j0j| | S)z3Adds a new overloaded method to a class definition.z)Overloads must contain at least two cases)r6specr|r}T)rdrrrr2rrr6rgset_lineline is_decoratedr is_overloadrris_class is_staticrrplugin_generatedrrrr)r=rr6r^r|r}funcsrkru_symvardeco overload_defrs r8add_overloaded_method_to_classrs5 u:?GGG?S$'(*E(  HH)+  d dG $dii+C LL # $D T2s+DD T%*%U+LL*L,L $ -CCCHHNN4HHMM""<0 r:c|j}|sJ||jvrd|j|}|jrIt|jt r/|j jj|j||jvr3t||j}|j||j|<yyrP) rrrr2rtrrrremover0)rr6rrr_names r8rr1s 88D K4 tzzjj   Jsxx$A HHMM  * tzz-dDJJ?!ZZ- 6r:c|\}}}} |dur |durJdt|tr|jd} n|jdg} |r6|xst t |}t td|dtdg} n0|rg} n+|xs t |}t td|dtg} | |z}ggg}} } |D]p}|jsJd| j|j| j|jj|j|jrt| || || }| rt| |_t#||t%t'g}||_t+|||_||_||_|j2dz|z|_|j6|_|rud|_t||j,}||_|j4|_d|_t=|g|}|j6|_t?t@|}d|_!||fSt?t@|}d|_!||fS)NTz@Can't add a new method that's both staticmethod and classmethod.zbuiltins.function_clsselfz"All arguments must be fully typed..)"r2r named_typenamed_generic_typer*r/r rrtype_annotationrvariabler6ror#tuple variablesrr rrr rgrrrh _fullnamerrr}rrrr)r=rr6rr|r}rFryrzr function_typefirstrerEr_rZ signatureruvdecrs r8rrDsE/3+D+y) $?d#:JIJ #67':; ../BBG >-*=!> #f+y$FG 4t!4 #f+y$@A 4DDIDM"D **+/(+F(!,t3& dT DJJt Kr:cht|}|jt|jd|S)NF) allow_missing)r,acceptrmodules)datar=rs r8deserialize_and_fixup_typers( 4 CJJyE:; Jr:)r5rr6strr7rireturnri) r5rr>r r6rr7rirri)rHr r6rrzExpression | None)rjr'rHr rr#)rHr rzCallableType | None)NNFF)r5rr6rrFrryr(rzrr{zTypeVarType | Noner|rir}rirrY)r=8SemanticAnalyzerPluginInterface | CheckerPluginInterfacerr r6rrFrryr(rzrr{z&list[TypeVarType] | TypeVarType | Noner|rir}rirzFuncDef | Decorator)FF)r=rrr r6rr^zlist[MethodSpec]r|rir}rirr)rr r6rrrY)r=rrrr6rrrr|rir}rirz+tuple[FuncDef | Decorator, SymbolTableNode])FFFNFF)r=rrr r6rrr(rrirrirrirhz str | Nonerrirrirr)rzstr | JsonDictr=rrr()G __future__rtypingr mypy.argmapr mypy.fixupr mypy.nodesrrr r r r r rrrrrrrrrrrr mypy.pluginrrrmypy.semanal_sharedrrrr mypy.typeopsr! mypy.typesr"r#r$r%r&r'r(r)r*r+r,r-mypy.types_utilsr. mypy.typevarsr/ mypy.utilr0r9r4r<rqrArrr~rrrrrrTr:r8rs". *a` N    1'22>B8"#' !       !  6// "7; ! A      5H!! . A. . .  .  .  ..b.&@ A@ @ @  @  @@1@P(-$* (* * *  *  *  *"&**** *Zr: