L i_) ddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#ddl"m$Z$dd l%m&Z&dd!l%m'Z' d(d"Z( d)d#Z) d*d$Z* d)d%Z+ d+d&Z,y'),) annotations)List)Optional)Union) ARG_NAMED_OPT)Argument)AssignmentStmt)CallExpr)ClassDef)MDEF) MemberExpr)NameExpr)RefExpr)StrExpr)SymbolTableNode)TempNode)TypeInfo)Var)SemanticAnalyzerPluginInterface)add_method_to_class)AnyType)get_proper_type)Instance)NoneTyp) ProperType) TypeOfAny) UnboundType) UnionType)infer)util)expr_to_mapped_constructor)NAMED_TYPE_SQLA_MAPPEDc t|tr |j}nt|tr |j}ny|j j D]O}t|tst|jdts2|jdj|k(sOntj|d||y|jtj|d|yt|j}t|tttfsJ|j!tj"||j$|j&||j(t+|||jd|dy)NrzCan't find mapped attribute zBStatement linked from _mypy_mapped_attrs has no typing information)namelinecolumntypinfo) isinstancerr%rvaluedefsbodyr lvaluesr!failtyperrrrappendSQLAlchemyAttributer&r'r)apply_type_to_mapped_statement)clsapiitem attributesr%stmtleft_hand_explicit_types _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/ext/mypy/apply.pyapply_mypy_mapped_attrr;-s@ $!yy D' "zz  t^ ,4<<?H5 Q$$,   #5dV>&&//3II+777!$*-A,B" CCJ ""388Z8QBsM+cl|j}t|tsJ|$d|_|j t |g|_n?d|_|j t |ttjgn|g|_t|j|_ |j |||_yyy)aApply the Mapped[] annotation and right hand object to a declarative assignment statement. This converts a Python declarative class statement such as:: class User(Base): # ... attrname = Column(Integer) To one that describes the final Python behavior to Mypy:: ... format: off class User(Base): # ... attrname : Mapped[Optional[int]] = ... format: on NF) r?r*ris_inferred_defrFr#r0rr special_formr"r@)r5r8lvaluer9rLrKs r:r3r3s: I i %% %*!& "%<$= "' "(///01*+  *-T[[9DK yy!5!A( "Br<c .tj||}|ytj|}d|jvr|s|Dcic]}|j|j }}|j ddD]W}d|jvrtj||}|+|D](}|j|j|j *Yg} |jD]U\} } | ttj} | jtt!| | | t#| t$Wt'||d| t)d|jvr#tj*|rt-||dd|st-||d d yycc}w) zCApply __init__, __table__ and other attributes to the mapped class.N__init__r sqlalchemy)variabletype_annotation initializerkind __table__zsqlalchemy.sql.schema.Tablezsqlalchemy.orm.mapper.Mapper __mapper__)r! info_for_cls get_is_basenamesr%r0mrometadataget_mapped_attributes setdefaultitemsrrrRr1rrrrrr get_has_table _apply_placeholder_attr_to_class) r4r5r7r)is_baserHmapped_attr_namesbasebase_cls_attributes argumentsr%r(s r:add_additional_orm_attributesrms   S# &D |t$G#G>HIdTYY 1IIHHQrN CD4==0"&"<"rsl#$%!&73&! " -)2 2 (2 #2/ 2  2jR9 R9 (R9/R9 R9jE) (E) E) E)2 E) / E)  E)P2 2 (2 /2  2 j: (: :: :  :r<