L iKrddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z" d(dZ# d)dZ$ d)dZ% d(d Z& d)d!Z' d* d+d#Z( d, d-d$Z) d.d%Z* d/d&Z+ d0d'Z,y")1) annotations)Optional)Sequence)map_instance_to_supertype)AssignmentStmt)CallExpr) Expression)FuncDef) LambdaExpr) MemberExpr)NameExpr)RefExpr)StrExpr)TypeInfo)Var)SemanticAnalyzerPluginInterface) is_subtype)AnyType) CallableType)get_proper_type)Instance)NoneType) ProperType) TypeOfAny) UnionType)names)utilctj|}|y|tjurt|||||}|S|tjurt ||||}|S|tj urt||||}|S|tjurt||||}|S|tjurt|||}|S|tjurt||||}|SyN)rtype_id_for_calleeMAPPED_infer_type_from_mappedCOLUMN_infer_type_from_decl_column RELATIONSHIP_infer_type_from_relationshipCOLUMN_PROPERTY%_infer_type_from_decl_column_propertySYNONYM_PROPERTY#infer_type_from_left_hand_type_onlyCOMPOSITE_PROPERTY(_infer_type_from_decl_composite_property)apistmtnodeleft_hand_explicit_typeinfer_from_right_sidetype_idpython_type_for_types _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/ext/mypy/infer.py#infer_type_from_right_hand_nameexprr6(s+&&'<=G ELL 6 t46K 4 / ELL ; t4 , ' E&& &< t4 $  E)) )D t4   E** *B .   E,, ,G t4  ct|jtsJ|jjd}d}t|tr2t|j t r|j }t|g}tj|jd}tj|jd}d} |=|j|dur*|(d} |&|jtj|g}n||j|duri|fd} t|tr |j}t|tr6t|j t r|t|j |g}nt|trt|j tr|j j |Ct|j j t"rt%|j j j&} t| t"rt%| j&} t| trt| j |g}ntj(|d|jd}n|N|j|dur;|!tj(|d|j|Jt+|t-g}n4|2d } tj(|| j/|j0|| t3|||S|B| r2t|tsJt|tsJt5||||St7||||S|S) aInfer the type of mapping from a relationship. E.g.:: @reg.mapped class MyClass: # ... addresses = relationship(Address, uselist=True) order: Mapped["Order"] = relationship("Order") Will resolve in mypy as:: @reg.mapped class MyClass: # ... addresses: Mapped[List[Address]] order: Mapped["Order"] rNuselistcollection_classFTz>Expected Python collection type for collection_class parameterzOSending uselist=False and collection_class at the same time does not make sensezCan't infer scalar or collection for ORM mapped expression assigned to attribute '{}' if both 'uselist' and 'collection_class' arguments are absent from the relationship(); please specify a type annotation on the left hand side.) isinstancervaluerargsr r0rrrget_callexpr_kwarg parse_bool named_typerNAMED_TYPE_BUILTINS_LISTcalleer typerrret_typefailrrformatnamer+3_infer_collection_type_from_left_and_inferred_right(_infer_type_from_left_and_inferred_right) r.r/r0r1target_cls_argr4related_object_type uselist_argcollection_cls_argtype_is_a_collectionrtcallable_ret_typemsgs r5r'r'PsA< dkk8 ,, ,[[%%a(N15.(+ X1-11'(;R@ ))$++yAK/3/F/F '0!  NN; '4 /  &#  +#&>>..1E0F$  s~~k:dB  (# (( 3!3!:!:  (( 3  # #X9 $/(0&++.B-C($ )8 4-22G<"'',,8#/ 055::LI();)@)@)E)E)N)NOB!"l3,;BKK,H)%&7B3; 1 6 6!5 640 II-   $(  S^^K%@E%I  ) II&   +#,%xz2$ # *9  IIc3::dii0$ 7#2 .   ! , 5x@ @@2H= ==FT24H <'$  $#r7c<t|jtsJ|jjd}d}t|tr3t|j t r|j }t|g}nd}| t|||S|t||||S|S)z+Infer the type of mapping from a Composite.rN) r;r<rr=r r0rrr+rI)r.r/r0r1rJr4rKs r5r-r-s dkk8 ,, ,[[%%a(N.(+ X1-11'(;R@##2 .   ! ,7 .0D  $#r7c~t|jtsJtj|}t |||S)zVInfer the type of mapping from a right side expression that returns Mapped. )r;r<rrtype_for_calleer+)r.r/r0r1r2the_mapped_types r5r#r#s@ dkk8 ,, ,**+@AO . T* r7ct|jtsJ|jjrj|jjd}t|trAt j |j }|tjurt|||||St|jtrIt j |jj }|tjurt||||St|||S)zInfer the type of mapping from a ColumnProperty. This includes mappings against ``column_property()`` as well as the ``deferred()`` function. r)right_hand_expression) r;r<rr=rr!rBr$r%QUERY_EXPRESSIONr+)r.r/r0r1first_prop_argr3s r5r)r)6s dkk8 ,, , {{))!, nh /..~/D/DEG%,,&3+*8 $++x(**4;;+=+=> e,, ,/'   / T* r7Nc"t|tsJd}|'t|jtsy|j}|jddD]}t|tr5t|j t s.|j }|j}n^t|ttfr!t|jtr|}d}n(t|tfrt|tfrJ|yt|jtrttj|jjtj r*C*CA*FG/ . mh %: ;; ; o)'< == = 3  /";  r7c|jd}tj||j|j||j t j ttjgS|S)zDetermine the type based on explicit annotation only. if no annotation were present, note that we need one there to know the type. zCan't infer type from ORM mapped expression assigned to attribute '{}'; please specify a Python type or Mapped[] on the left hand side.) rrErFrGr@rrdrr special_form)r.r0r1rQs r5r+r+se& ; #szz$)),d3~~  ( (793I3I+J*K  '&r7cL|jdk(r|r|d}t|tr]t|jtrC|jj D])}|jdk(st |jgcSn |jtjgS|jds Jd|z|jd}|t|jtsJtt |g|j}t|jdS)Nzsqlalchemy.sql.sqltypes.Enumrz enum.Enumz"sqlalchemy.sql.type_api.TypeEnginez+could not extract Python type from node: %s)fullnamer;rr0rr^rr@rNAMED_TYPE_BUILTINS_STRhas_baselookup_fully_qualified_or_nonerrr=)r.r0rb first_argbase_type_engine_sym type_engines r5r`r`.s  }}669aL i )j NNH/ #++ 8>>[0#INNB77 8 >>%"?"?D D === >5< >88,O  &:h, ,rK ;++B/ 00r7) r.rr/rr0rr1Optional[ProperType]r2rreturnry) r.rr/rr0rr1ryrzryr ) r.rr/rr0rr1ryrWzOptional[CallExpr]rzry)NN)r.rr0rr1rr4rrgryrhryrzry) r.rr0rr1rr4rrzry)r.rr0rr1ryrzry)r.rr0rrbzSequence[Expression]rzr)- __future__rtypingrr mypy.maptyper mypy.nodesrrr r r r r rrrr mypy.pluginr mypy.subtypesr mypy.typesrrrrrrrrrrr6r'r-r#r)r%rIrHr+r`r\r7r5rs#2%!!!7$#&! % (% %  % 2 % # %  % Pc$ (c$ c$ c$2 c$  c$L$ ($ $ $2 $  $@ (  2  #   @. (. . .2 .  .l15 ` (` `  ` 2 ` . `  ` P156: ' (' '('% ' . ' 4 ''T ( &#   :' (' '2' ': 1 ( 1  1$ 1 1r7