
    -hEG                        S SK Jr  S SK Jr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SKJ
r
  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  SSKJr  SSKJ r   S\S\S\S\\   S \S!\\   4S" jr!S\S\S\S\\   S!\\   4
S# jr"S\S\S\S\\   S!\\   4
S$ jr#S\S\S\S\\   S!\\   4
S% jr$ S1S\S\S\S\\   S'\\   S!\\   4S( jjr%  S2S\S\S\S)\S*\\   S+\\   S!\\   4S, jjr&S\S\S\S)\S!\\   4
S- jr'S\S\S\\   S!\\   4S. jr(S\S\S/\\   S!\4S0 jr)g&)3    )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)utilapistmtnodeleft_hand_explicit_typeinfer_from_right_sidereturnc                    [         R                  " U5      nUc  g U[         R                  L a  [        XX#5      nU$ U[         R                  L a  [        XX#5      nU$ U[         R                  L a  [        XX#5      nU$ U[         R                  L a  [        XU5      nU$ U[         R                  L a  [        XX#5      nU$ g N)r   type_id_for_calleeCOLUMN_infer_type_from_decl_columnRELATIONSHIP_infer_type_from_relationshipCOLUMN_PROPERTY%_infer_type_from_decl_column_propertySYNONYM_PROPERTY#infer_type_from_left_hand_type_onlyCOMPOSITE_PROPERTY(_infer_type_from_decl_composite_property)r   r   r    r!   r"   type_idpython_type_for_types          nC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/ext/mypy/infer.py#infer_type_from_right_hand_nameexprr4   ,   s     &&'<=G	ELL	 ;t 
,  ' 
E&&	&<t 
$   
E))	)Dt 
   
E**	*B. 
   
E,,	,Gt 
       c                 N   [        UR                  [        5      (       d   eUR                  R                  S   nSn[        U[        5      (       a7  [        UR
                  [        5      (       a  UR
                  n[        U/ 5      n[        R                  " UR                  S5      n[        R                  " UR                  S5      nSn	Ub?  U R                  U5      SL a+  Uc(  Sn	Ub!  U R                  [        R                  U/5      nGO5Ub  U R                  U5      SL Ga  UGb  Sn	[        U[        5      (       a  UR                  n[        U[        5      (       a;  [        UR
                  [        5      (       a  Ub  [        UR
                  U/5      nGO[        U[        5      (       a  [        UR
                  [        5      (       a  UR
                  R                   b  Ub  [        UR
                  R                   ["        5      (       a  [%        UR
                  R                   R&                  5      n
[        U
["        5      (       aA  [%        U
R&                  5      n[        U[        5      (       a  [        UR                   U/5      nO[        R(                  " U SUR                  5        SnOUbR  U R                  U5      SL a>  Ub"  [        R(                  " U SUR                  5        Ub  [+        U[-        5       /5      nO5Uc2  S	n[        R(                  " XR/                  UR0                  5      U5        Uc  [3        XU5      $ UbO  U	(       a:  [        U[        5      (       d   e[        U[        5      (       d   e[5        XX55      $ [7        U UUU5      $ U$ )
ar  Infer 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"]

r   Nuselistcollection_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.)
isinstancervaluer   argsr   r    r   r   r   get_callexpr_kwarg
parse_bool
named_typer   NAMED_TYPE_BUILTINS_LISTcalleer	   typer   r   ret_typefailr   r   formatnamer.   3_infer_collection_type_from_left_and_inferred_right(_infer_type_from_left_and_inferred_right)r   r   r    r!   target_cls_argr2   related_object_typeuselist_argcollection_cls_argtype_is_a_collectionrtcallable_ret_typemsgs                r3   r*   r*   R   sg   < dkk8,,,,[[%%a(N15.(++
X1 1 -11'(;R@  ))$++yAK/3/F/F'0 ! 	NN;'4/&#+#&>>..1E0F$  	s~~k:dB

(#((33!3!:!:((33
##X9
 9
 $/ (0&++.B-C($ )844-22G<<"'',,8#/
 055::LII();)@)@)E)E)N)NOB!"l33,;BKK,H)%&7BB3; 1 6 6!5 640
 II-	 $( 		 S^^K%@E%I)II&	  +#,%xz2$ 
 #*9  IIc::dii0$7#2.
 	
 
!	,5x@@@@2H====F2  <'$	  $#r5   c                 X   [        UR                  [        5      (       d   eUR                  R                  S   nSn[        U[        5      (       a8  [        UR
                  [        5      (       a  UR
                  n[        U/ 5      nOSnUc  [        XU5      $ Ub  [        XX55      $ U$ )z3Infer the type of mapping from a CompositeProperty.r   N)
r9   r:   r   r;   r   r    r   r   r.   rG   )r   r   r    r!   rH   r2   rI   s          r3   r0   r0      s     dkk8,,,,[[%%a(N.(++
X1 1 -11'(;R@##2.
 	
 
!	,7.
 	
 $#r5   c                 B   [        UR                  [        5      (       d   eUR                  R                  (       an  UR                  R                  S   n[        U[        5      (       a@  [        R
                  " UR                  5      nU[        R                  L a  [        U UUUUS9$ [        UR                  [        5      (       aK  [        R
                  " UR                  R                  5      nU[        R                  L a  [        U UUU5      $ [        XU5      $ )zInfer the type of mapping from a ColumnProperty.

This includes mappings against ``column_property()`` as well as the
``deferred()`` function.

r   )right_hand_expression)r9   r:   r   r;   r   r&   r@   r'   r(   QUERY_EXPRESSIONr.   )r   r   r    r!   first_prop_argr1   s         r3   r,   r,     s     dkk8,,,,{{))!,nh//..~/D/DEG %,,&3+*8  $++x((**4;;+=+=> e,,,/'	  /* r5   NrR   c                    [        U[        5      (       d   eSnUc,  [        UR                  [        5      (       d  gUR                  nUR                  SS  H  n[        U[        5      (       a;  [        UR
                  [        5      (       a  UR
                  nUR                  n  OxMS  [        U[        [        45      (       a'  [        UR                  [        5      (       a  UnSn  O6M  [        U[        45      (       a  M  [        U[        45      (       a  M   e   Uc  g[        UR                  [        5      (       ax  [        R                  " UR                  R                  [        R                   5      (       a:  [#        XR                  W5      nUb  [%        XX85      $ ['        U[)        5       /5      $ [+        XU5      $ )a  Infer the type of mapping from a Column.

E.g.::

    @reg.mapped
    class MyClass:
        # ...

        a = Column(Integer)

        b = Column("b", String)

        c: Mapped[int] = Column(Integer)

        d: bool = Column(Boolean)

Will resolve in MyPy as::

    @reg.mapped
    class MyClass:
        # ...

        a : Mapped[int]

        b : Mapped[str]

        c: Mapped[int]

        d: Mapped[bool]

Nr       )r9   r   r:   r   r;   r@   r   r   r   r    r   r   r
   r   
mro_has_idmro
TYPEENGINE#extract_python_type_from_typeenginerG   r   r   r.   )	r   r   r    r!   rR   r@   
column_arg	type_argsr2   s	            r3   r(   r(   I  s   L dC    F$$++x00 $+0015
j(++*++W55#**2<//		 6
 
Xz$:;;*//844#	 
WJ//
ZM22 51 64 ~&++x((U-=-=)). .  Ci 
 #.;2 
 2HJ?@@ 3.
 	
r5   r2   orig_left_hand_typeorig_python_type_for_typec                 ^   Uc  UnUc  Un[        X#5      (       d  U R                  [        R                  U/5      nSn[        R
                  " U UR                  UR                  [        R                  " X@R                  5      [        R                  " X`R                  5      5      U5        U$ )zValidate type when a left hand annotation is present and we also
could infer the right hand side::

    attrname: SomeType = Column(SomeDBType)

zRLeft hand assignment '{}: {}' not compatible with ORM mapped expression of type {})
r   r>   r   NAMED_TYPE_SQLA_MAPPEDr   rC   rD   rE   format_typeoptions)r   r    r!   r2   r^   r_   effective_typerO   s           r3   rG   rG     s     "5 ($8!-DD((+D*E

4 	 			JJ		  !4kkB  =
 	
 r5   c           	      &   UnUnUR                   (       a1  [        UR                   S   5      n[        UR                   S   5      nOUnUn[        U[        [        45      (       d   e[        U[        [        45      (       d   e[        U UUUUUS9$ )Nr   )r^   r_   )r;   r   r9   r   r   rG   )r   r    r!   r2   r^   r_   left_hand_argpython_type_args           r3   rF   rF     s     2 4##'(?(D(DQ(GH)*>*C*CA*FG/.mh	%:;;;;o)'<====3/"; r5   c                     Ucj  Sn[         R                  " XR                  UR                  5      U5        U R	                  [
        R                  [        [        R                  5      /5      $ U$ )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[<python type>] on the left hand side.)
r   rC   rD   rE   r>   r   ra   r   r   special_form)r   r    r!   rO   s       r3   r.   r.     sc     &; 	 			#zz$)),d3~~((793I3I+J*K
 	
 '&r5   r]   c                    UR                   S:X  a  U(       a  US   n[        U[        5      (       ae  [        UR                  [        5      (       aF  UR                  R
                   H+  nUR                   S:X  d  M  [        UR                  / 5      s  $    O U R                  [        R                  / 5      $ UR                  S5      (       d
   SU-  5       eU R                  S5      nUb  [        UR                  [        5      (       d   e[        [        U/ 5      UR                  5      n[        UR                  S   5      $ )Nzsqlalchemy.sql.sqltypes.Enumr   z	enum.Enumz"sqlalchemy.sql.type_api.TypeEnginez+could not extract Python type from node: %s)fullnamer9   r   r    r   rY   r   r>   r   NAMED_TYPE_BUILTINS_STRhas_baselookup_fully_qualified_or_noner   r   r;   )r   r    r]   	first_argbase_type_engine_symtype_engines          r3   r[   r[     s$   
 }}669aL	i))jNNH/
 /
 #++>>[0#INNB77 ,
 >>%"?"?DD===>> 5<> 88,O &:h, ,   ,rK ;++B/00r5   r%   )NN)*typingr   r   mypy.maptyper   
mypy.nodesr   r   r   r	   r
   r   r   r   r   r   r   mypy.pluginr   mypy.subtypesr   
mypy.typesr   r   r   r   r   r   r   r    r   r   r4   r*   r0   r,   r(   rG   rF   r.   r[   rW   r5   r3   <module>r{      s     2 %  !  ! !      7 $  # &   !      # 	(# 
#  #  &j1	# 
 ##  j# Lc$	(c$
c$ c$ &j1	c$
 jc$L$	($
$ $ &j1	$
 j$@.	(.
. . &j1	.
 j.l 15a
	(a

a
 a
 &j1	a

 $H-a
 ja
R 156:'	('
' (' %	'
 "*-'  (
3' j'T	(
 & #	
 j:'	('
' &j1' j	': 1	( 1
 1 
# 1 	 1r5   