Ë
    pPêj`  ã                  ó4  — U d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z
 ddlmZmZmZmZmZ ddlmZ ddlmZmZmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3 dZ4de5d<   dZ6de5d<   dZ7de5d<   	 	 	 d'	 	 	 	 	 	 	 	 	 	 	 d(d„Z8	 	 	 	 	 	 	 	 	 	 d)d„Z9	 	 	 	 	 	 	 	 	 	 d*d„Z:d+d„Z;d,d„Z<	 	 	 	 	 	 d-d„Z=d.d/d„Z>d0d„Z?	 	 	 	 	 	 d1d„Z@d2d„ZA	 	 	 	 	 	 	 	 	 	 d3d „ZBd4d!„ZCd5d"„ZDd6d#„ZE	 	 	 	 	 	 	 	 d7d$„ZFd8d%„ZGy&)9z!Type inference constraint solvingé    )Úannotations)Údefaultdict)ÚIterableÚSequence)Ú	TypeAlias)Ú
SUBTYPE_OFÚSUPERTYPE_OFÚ
ConstraintÚinfer_constraintsÚneg_op)Úexpand_type)Úprepare_sccsÚstrongly_connected_componentsÚtopsort)Újoin_type_list)Úmeet_type_listÚ
meet_types)Ú
is_subtype)Úget_all_type_vars)ÚAnyTypeÚInstanceÚNoneTypeÚ
OverloadedÚParamSpecTypeÚ
ProperTypeÚ	TupleTypeÚTypeÚ	TypeOfAnyÚ	TypeVarIdÚTypeVarLikeTypeÚTypeVarTupleTypeÚTypeVarTypeÚUninhabitedTypeÚ	UnionTypeÚ
UnpackTypeÚget_proper_type)Ú
type_statezdict[TypeVarId, set[Type]]Ú
_TypeAliasÚBoundsz set[tuple[TypeVarId, TypeVarId]]ÚGraphzdict[TypeVarId, Type | None]Ú	Solutionsc           	     ó  — | D �cg c]  }|j                   ‘Œ }}|sg g fS | D �ci c]  }|j                   |“Œ }}g }|D ]Š  }	|j                  |	j                  D �
cg c]   }
|
j                   ||z   vsŒ|
j                   ‘Œ" c}
«       |j                  |	j                  D �
ci c]  }
|
j                   |vsŒ|
j                   |
“Œ  c}
«       ŒŒ |rt	        |«      }||z   D �ci c]  }|g “Œ }}|D ]2  }|j
                  ||z   v sŒ||j
                     j                  |«       Œ4 |r|rt        ||z   |||«      \  }}n±i }g }n¬i }g }|j                  «       D ]•  \  }}|sŒ	|D �	cg c]"  }	|	j                  t        k(  sŒ|	j                  ‘Œ$ }}	|D �	cg c]"  }	|	j                  t        k(  sŒ|	j                  ‘Œ$ }}	t        ||«      }|� t        ||D �cg c]	  }||vsŒ|‘Œ c}«      rŒ‘||<   Œ— g }|D ]Y  }
|
|v r|j                  ||
   «       Œ|rt        «       }d|_        nt#        t$        j&                  «      }|j                  |«       Œ[ |s|st)        || |«      }||fS c c}w c c}w c c}
w c c}
w c c}w c c}	w c c}	w c c}w )a§  Solve type constraints.

    Return the best type(s) for type variables; each type can be None if the value of
    the variable could not be solved.

    If a variable has no constraints, if strict=True then arbitrarily
    pick UninhabitedType as the value of the type variable. If strict=False, pick AnyType.
    If allow_polymorphic=True, then use the full algorithm that can potentially return
    free type variables in solutions (these require special care when applying). Otherwise,
    use a simplified algorithm that just solves each type variable individually if possible.

    The skip_unsatisfied flag matches the same one in applytype.apply_generic_arguments().
    T)ÚidÚextendÚextra_tvarsÚupdateÚskip_reverse_union_constraintsÚtype_varÚappendÚsolve_with_dependentÚitemsÚopr	   Útargetr   Ú	solve_oneÚget_varsr#   Ú	ambiguousr   r   Úspecial_formÚpre_validate_solutions)Úoriginal_varsÚconstraintsÚstrictÚallow_polymorphicÚskip_unsatisfiedÚtvÚvarsÚ	originalsÚ
extra_varsÚcÚvÚcmapÚconÚ	solutionsÚ	free_varsÚcsÚlowersÚuppersÚsolutionÚresÚ	candidates                        úO/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/mypy/solve.pyÚsolve_constraintsrS   *   s¢  € ð( *Ö*�bˆB�E‹EÐ*€DÐ*ÙØ�2ˆvˆà%2Ö3˜r�—‘˜‘Ð3€IÐ3Ø"$€Jàò TˆØ×Ñ¨¯©ÖX A¸!¿$¹$ÀdÈZÑFWÒ:W˜1Ÿ4›4ÒXÔYØ×Ñ¨1¯=©=ÖR a¸A¿D¹DÈ	Ò<Q˜!Ÿ$™$ ™'ÒRÕSðTñ ä4°[ÓAˆð AEÀzÑ@QÖ.R¸"¨r°2©vÐ.R€DÐ.RØò +ˆØ�<‰<˜4 *Ñ,Ò,Ø�—‘Ñ×%Ñ% cÕ*ð+ñ ÙÜ#7Ø�zÑ! ;°°ió$Ñ ˆI‘yð ˆIØ‰Iàˆ	Øˆ	Ø—j‘j“lò 	)‰FˆB�ÙØØ(*ÖC 1¨a¯d©d´lÓ.B�a—h“hÐCˆFÐCØ(*ÖA 1¨a¯d©d´jÓ.@�a—h“hÐAˆFÐAÜ  ¨Ó0ˆHð Ð¤xØ¨
ÖE "°bÀ²nš2ÒEõ(ð !)�	˜"’ð	)ð  €CØò "ˆØ�	‰>Ø�J‰J�y ‘|Õ$ñ Ü+Ó-�	Ø&*�	Õ#ä#¤I×$:Ñ$:Ó;�	Ø�J‰J�yÕ!ð"ñ Ñ-ô % S¨-¸ÓEˆà�	ˆ>ÐùòC +ùò 4ùò YùÚRùò /Sùò& DùÚAùò
 FsL   …I!¤I&ÁI+
Á1I+
ÂI0
Â3I0
Ã
I5Å!I:Å:I:ÆI?Æ'I?Ç	JÇJc                óR  ‡‡— t        | |«      \  }ŠŠt        | |‰‰«      }t        t        t	        | «      |«      «      }t        ˆˆfd„|D «       «      si g fS t        t        t        ||«      «      «      }g }i }	|d   D ]b  }
t        ˆˆfd„|
D «       «      sŒt        |
D �cg c]  }||   ‘Œ	 c}|«      }|sŒ9|j                  |j                  «       ||	|j                  <   Œd |D ]<  \  }}||v r‰|   j                  |	|   «       ||v sŒ&‰|   j                  |	|   «       Œ> g }|D ]6  }g }|D ]  }
|j                  t        |
«      «       Œ |j                  |«       Œ8 i }|D ]!  }t        ||‰‰«      }|j                  |«       Œ# ||D �cg c]  }|	|   ‘Œ	 c}fS c c}w c c}w )aS  Solve set of constraints that may depend on each other, like T <: List[S].

    The whole algorithm consists of five steps:
      * Propagate via linear constraints and use secondary constraints to get transitive closure
      * Find dependencies between type variables, group them in SCCs, and sort topologically
      * Check that all SCC are intrinsically linear, we can't solve (express) T <: List[T]
      * Variables in leaf SCCs that don't have constant bounds are free (choose one per SCC)
      * Solve constraints iteratively starting from leaves, updating bounds after each step.
    c              3  ó8   •K  — | ]  }t        |‰‰«      –— Œ y ­w©N)Úcheck_linear)Ú.0ÚsccrM   rN   s     €€rR   ú	<genexpr>z'solve_with_dependent.<locals>.<genexpr>•   s   øè ø€ ÒA°SŒ|˜C ¨×0ÑAùs   ƒr   c              3  ó:   •K  — | ]  }‰|    xr ‰|    –— Œ y ­wrV   © )rX   rB   rM   rN   s     €€rR   rZ   z'solve_with_dependent.<locals>.<genexpr>Ÿ   s%   øè ø€ Ò?°R�6˜"‘:ˆ~Ò0 f¨R¡j .Ó0Ñ?ùs   ƒ)Útransitive_closureÚcompute_dependenciesÚlistr   ÚsetÚallr   r   Úchoose_freer3   r-   Úaddr.   Úsolve_iterativelyr0   )rC   r>   r=   rD   ÚgraphÚdmapÚsccsÚraw_batchesrK   Úfree_solutionsrY   rB   Ú	best_freeÚlÚuÚbatchesÚbatchÚnext_bcrJ   Ú
flat_batchrP   rM   rN   s                        @@rR   r4   r4   ‚   sÇ  ù€ ô /¨t°[ÓAÑ€Eˆ6�6ä  e¨V°VÓ<€DÜÔ-¬c°$«i¸Ó>Ó?€DÜÔA¸DÔAÔAØ�2ˆvˆÜ”wœ|¨D°$Ó7Ó8Ó9€Kà€IØ€NØ˜1‰~ò 
9ˆô Ô?¸3Ô?Õ?Ü#¸SÖ$A°r Y¨r£]Ò$AÀ=ÓQˆIÚð × Ñ  §¡Ô.Ø/8�˜yŸ|™|Ò,ð
9ð ò -‰ˆˆ1Ø�	‰>Ø�1‰I�M‰M˜.¨Ñ+Ô,Ø�	Š>Ø�1‰I�M‰M˜.¨Ñ+Õ,ð	-ð €GØò  ˆØˆØò 	&ˆCØ�N‰Nœ4 ›9Õ%ð	&à�‰�wÕð	 ð /1€IØò ˆ
Ü 
¨E°6¸6ÓBˆØ×Ñ˜Õðð °IÖ>¨b�~ bÓ)Ò>Ð>Ð>ùò9 %Bùò8 ?s   Â!F
ÆF$c                óº  — i }t        | «      }|rÇt        |d„ ¬«      D ]  }||   s||   sŒ|} n n¥|j                  |«       t        ||   ||   «      }|||<   |€ŒO|j	                  «       D ]d  \  }	}
|	|
k(  rŒ|	|k(  r'||
   j                  |«       |j                  |	|
f«       |
|k(  sŒ>||	   j                  |«       |j                  |	|
f«       Œf |rŒÇ|j                  «       D ��ci c]  \  }}|€Œ	||“Œ }}}|D ]"  }||   D �ch c]  }t        ||«      ’Œ c}||<   Œ$ |D ]"  }||   D �ch c]  }t        ||«      ’Œ c}||<   Œ$ |S c c}}w c c}w c c}w )a°  Solve transitive closure sequentially, updating upper/lower bounds after each step.

    Transitive closure is represented as a linear graph plus lower/upper bounds for each
    type variable, see transitive_closure() docstring for details.

    We solve for type variables that appear in `batch`. If a bound is not constant (i.e. it
    looks like T :> F[S, ...]), we substitute solutions found so far in the target F[S, ...]
    after solving the batch.

    Importantly, after solving each variable in a batch, we move it from linear graph to
    upper/lower bounds, this way we can guarantee consistency of solutions (see comment below
    for an example when this is important).
    c                ó   — | j                   S rV   )Úraw_id)Úxs    rR   ú<lambda>z#solve_iteratively.<locals>.<lambda>Ò   s
   € °·±€ ó    ©Úkey)r`   ÚsortedÚremover8   Úcopyrc   r5   r   )rn   re   rM   rN   rJ   Ús_batchrB   Úsolvable_tvÚresultrk   rl   ÚsÚsubsÚltÚuts                  rR   rd   rd   ¿   s‘  € ð  €IÜ�%‹j€GÙ
Ü˜Ñ&8Ô9ò 	ˆBØ�bŠz˜V B›ZØ �Ùð	ð
 à�‰�{Ô#Ü˜6 +Ñ.°°{Ñ0CÓDˆØ!'ˆ	�+ÑØˆ>ð ð —J‘J“Lò 	%‰DˆAˆqØ�AŠvØØ�KÒØ�q‘	—‘˜fÔ%Ø—‘˜a ˜VÔ$Ø�KÓØ�q‘	—‘˜fÔ%Ø—‘˜a ˜VÕ$ð	%ò+ ðD "+§¡Ó!2×D‘g�r˜1°a±mˆB�‰EÐD€DÑDØò BˆØ6<¸R±jÖA°”k " dÕ+ÒAˆˆrŠ
ðBàò BˆØ6<¸R±jÖA°”k " dÕ+ÒAˆˆrŠ
ðBàÐùó EùâAùâAs   Ã*
EÃ5EÄ	EÄ0Ec                ó€   — t        | «      } t        | t        «      ryt        | t        «      ryt        | t        «      ryy)Néþÿÿÿéÿÿÿÿé   r   )r&   Ú
isinstancer$   r   r   )Úts    rR   Ú_join_sorted_keyr‰   û   s6   € Ü˜Ó€AÜ�!”YÔØÜ�!”XÔØä�!”ZÔ ØØrv   c                óê  — d}g }|D ];  }t        |«      }t        |t        «      r|j                  rŒ+|j	                  |«       Œ= |}t        | «      } |s| st        «       }d|_        |S d}d}t        j                  r| rt        j                  | «      }nt        | t        ¬«      }|rt        |«      }|D ]  }	|€|	}Œt        ||	«      }Œ t        |«      }
t        |«      }t        |
t        «      st        |t        «      rQt        |
t        «      r|n|}t        |t        «      rt        |t        «      sJ ‚t        t         j"                  |¬«      S |€|r|}|S y|€|}|S t%        ||«      r|}|S d}|S )zWSolve constraints by finding by using meets of upper bounds, and joins of lower bounds.NTrw   )Ú
source_any)r&   r‡   r#   r:   r3   r_   r'   Úinfer_unionsr$   Ú
make_unionry   r‰   r   r   r   r   r   Úfrom_another_anyr   )rM   rN   rQ   Ú
new_uppersrl   ÚpuÚbottomÚtopÚsorted_lowersr7   Úp_topÚp_bottomr‹   s                rR   r8   r8     s•  € ð "€Ið €JØò !ˆÜ˜QÓˆÜ˜"œoÔ.°b·l³lØ×Ñ˜aÕ ð!ð €Fô �&‹\€FÙ™&Ü#Ó%ˆ	Ø"ˆ	ÔØÐà€FØ€Cô
 ×Ò¡6ô ×%Ñ% fÓ-‰ô ˜vÔ+;Ô<ˆÙÜ# MÓ2ˆFàò *ˆØˆ;Ø‰Cä˜S &Ó)‰Cð	*ô ˜CÓ €EÜ˜vÓ&€HÜ�%œÔ!¤Z°¼'Ô%BÜ& u¬gÔ6‘S¸Fˆ
Ü˜*¤jÔ1´jÀÌWÔ6UÐUÐUÜ”y×1Ñ1¸jÔIÐIØ	ˆÙØˆIð Ðð Ø	ˆØˆ	ð
 Ðô	 
�F˜CÔ	 Øˆ	ð Ðð ˆ	ØÐrv   c                óê  ‡— t        | «      dk(  r| d   S t        | D �cg c]  }|j                  ‘Œ c}«      }t        |«      }t	        |t
        t        f«      ryg }| D ]>  }t	        |t        «      sŒ|j                  sŒ!|r y|j                  j                  «       }Œ@ |rt        |«      syt        | ˆfd„¬«      }t	        |t        «      r|j                  ||¬«      S t        |d¬«      r|S yc c}w )	a  Choose the best solution for an SCC containing only type variables.

    This is needed to preserve e.g. the upper bound in a situation like this:
        def dec(f: Callable[[T], S]) -> Callable[[T], S]: ...

        @dec
        def test(x: U) -> U: ...

    where U <: A.
    r†   r   Nc                óL   •— | j                   ‰v| j                   j                  fS rV   )r-   rs   )rt   r=   s    €rR   ru   zchoose_free.<locals>.<lambda>v  s   ø€  1§4¡4¨}Ð#<¸a¿d¹d¿k¹kÐ"J€ rv   rw   )ÚvaluesÚupper_boundT)Úallow_tuple)Úlenr   r™   r&   r‡   r#   r   r"   r˜   r{   Úis_trivial_boundÚminÚcopy_modified)rY   r=   rˆ   Úcommon_upper_boundÚcommon_upper_bound_pr˜   rB   Úbests    `      rR   rb   rb   L  sì   ø€ ô ˆ3ƒx�1‚}à�1‰vˆä'ÀÖ(D¸1¨¯«Ò(DÓEÐÜ*Ð+=Ó>ÐäÐ&¬¼(Ð(CÔDð à€FØò &ˆÜ�bœ+Õ&¨2¯9«9Ùñ Ø—Y‘Y—^‘^Ó%‰Fð&ñ Ô&Ð';Ô<ð ô ˆsÓJÔK€DÜ�$œÔ$Ø×!Ñ!¨Ð=OÐ!ÓPÐPÜÐ,¸$Õ?àˆØùò= )Es   žC0c                óô   — t        | t        «      r>| j                  j                  dk(  r%|xr! t	        t        | j                  d   «      «      S t        | t        «      xr | j                  j                  dk(  S )Nzbuiltins.tupler   zbuiltins.object)r‡   r   ÚtypeÚfullnamerœ   r&   Úargs)Útprš   s     rR   rœ   rœ     s^   € Ü�"”hÔ B§G¡G×$4Ñ$4Ð8HÒ$HØÒLÔ/´ÀÇÁÈÁ
Ó0KÓLÐLÜ�bœ(Ó#ÒM¨¯©×(8Ñ(8Ð<MÑ(MÐMrv   c                óÄ  — t        | j                  t        «      r2t        | j                  t        «      rd| j                  j                  fS t        | j                  t
        «      rRt        | j                  t
        «      r8| j                  j                  j                  sd| j                  j                  fS t        | j                  t        «      rŽt        | j                  «      }t        |t        «      rit        |j                  «      dk(  rQ|j                  d   }t        |t        «      r2t        |j                  t        «      rd|j                  j                  fS y)zUFind out if this constraint represent a linear relationship, return target id if yes.Tr†   r   )FN)r‡   Úorigin_type_varr"   r7   r-   r   ÚprefixÚ	arg_typesr!   r&   r   r›   r5   r%   r£   )rF   r7   Úitems      rR   Úfind_linearr¬   …  sè   € ä�!×#Ñ#¤[Ô1Ü�a—h‘h¤Ô,Ø˜Ÿ™Ÿ™Ð$Ð$Ü�!×#Ñ#¤]Ô3Ü�a—h‘h¤Ô.°q·x±x·±×7PÒ7PØ˜Ÿ™Ÿ™Ð$Ð$Ü�!×#Ñ#Ô%5Ô6Ü  §¡Ó*ˆÜ�fœiÔ(¬S°·±Ó->À!Ò-CØ—<‘< ‘?ˆDÜ˜$¤
Ô+´
¸4¿9¹9ÔFVÔ0WØ˜TŸY™YŸ\™\Ð)Ð)Ørv   c                óÂ  — t        t        «      }t        t        «      }| D �ch c]  }||f’Œ }}t        |«      }|�r|j                  «       }t        |«      \  }}	|rÊ|	| v rÆ|	€J ‚|j                  t
        k(  r|j                  |	}}
n|	|j                  }}
|
|f|v rŒb|| D ��ch c]  }| D ]  }||
f|v sŒ
||f|v sŒ||f’Œ Œ c}}z  }| D ]  }||f|v sŒ
||xx   ||
   z  cc<   Œ | D ]  }||
f|v sŒ
||xx   ||   z  cc<   Œ ||
   D ]  }||   D ]  }t        |||«       Œ Œ �n%|j                  t
        k(  r|j                  ||j                     v r�Œ| D ]1  }||j                  f|v sŒ||   j                  |j                  «       Œ3 ||j                     D ]  }t        |||j                  «       Œ n“|j                  t        k(  sJ ‚|j                  ||j                     v r�Œ±| D ]1  }|j                  |f|v sŒ||   j                  |j                  «       Œ3 ||j                     D ]  }t        ||j                  |«       Œ |r�Œ|||fS c c}w c c}}w )aw  Find transitive closure for given constraints on type variables.

    Transitive closure gives maximal set of lower/upper bounds for each type variable,
    such that we cannot deduce any further bounds by chaining other existing bounds.

    The transitive closure is represented by:
      * A set of lower and upper bounds for each type variable, where only constant and
        non-linear terms are included in the bounds.
      * A graph of linear constraints between type variables (represented as a set of pairs)
    Such separation simplifies reasoning, and allows an efficient and simple incremental
    transitive closure algorithm that we use here.

    For example if we have initial constraints [T <: S, S <: U, U <: int], the transitive
    closure is given by:
      * {} <: T <: {int}
      * {} <: S <: {int}
      * {} <: U <: {int}
      * {T <: S, S <: U, T <: U}
    )r   r`   Úpopr¬   r6   r   r2   Úadd_secondary_constraintsr7   rc   r	   )Útvarsr>   rN   rM   rB   re   Ú	remainingrF   Ú	is_linearÚ	target_idÚlowerÚupperrk   rl   r�   r‚   s                   rR   r]   r]   –  s¶  € ô, !¤Ó%€FÜ ¤Ó%€FØ',Ö- �R˜’HÐ-€EÐ-ä�KÓ €IÚ
Ø�M‰M‹Oˆô
  +¨1›~Ñˆ	�9Ù˜ eÑ+ØÐ(Ð(Ð(Ø�t‰t”zÒ!Ø Ÿz™z¨9�u‘à(¨!¯*©*�u�Ø�uˆ~ Ñ&ØØØ %÷Ø¨uòØ*+¸¸E¸
ÀeÒ8KÐQVÐXYÐPZÐ^cÒPc��A’ðØóñ ˆEð ò /�Ø˜1�: Ò&Ø˜1“I ¨¡Ñ.”Ið/ð ò /�Ø�u�: Ò&Ø˜1“I ¨¡Ñ.”Ið/ð ˜U‘mò A�Ø  ™-ò A�BÜ-¨i¸¸RÕ@ñAòAð �T‰T”ZÒØ�x‰x˜6 !§*¡*Ñ-Ñ-ÙØò ,�Ø�q—z‘z�? eÒ+Ø˜1‘I—M‘M !§(¡(Õ+ð,ð ˜QŸZ™ZÑ(ò C�Ü)¨)°R¸¿¹ÕBñCð —4‘4œ<Ò'Ð'Ð'Ø�x‰x˜6 !§*¡*Ñ-Ñ-ÙØò ,�Ø—J‘J �? eÒ+Ø˜1‘I—M‘M !§(¡(Õ+ð,ð ˜QŸZ™ZÑ(ò C�Ü)¨)°Q·X±X¸rÕBðCóU ðX �&˜&Ð Ð ùò_ .ùó$s   £IÂ#IÂ4IÂ;Ic           	     ó  — t        t        |«      t        «      rt        t        |«      t        «      ry| j                  t	        t        ||t        «      «      «       | j                  t	        t        ||t        «      «      «       y)zFAdd secondary constraints inferred between lower and upper (in place).N)r‡   r&   r$   r0   r`   r   r   r	   )rL   r´   rµ   s      rR   r¯   r¯   à  s]   € ä”/ %Ó(¬)Ô4¼Ü˜Ó¤	ô:ð 	à‡I�IŒcÔ# E¨5´*Ó=Ó>Ô?Ø‡I�IŒcÔ# E¨5´,Ó?Ó@ÕArv   c                ó  — i }| D ]w  }t        «       }||   D ]  }|t        || «      z  }Œ ||   D ]  }|t        || «      z  }Œ | D ]&  }	|	|k(  rŒ	||	f|v s|	|f|v sŒ|j                  |	«       Œ( t        |«      ||<   Œy |S )zÛCompute dependencies between type variables induced by constraints.

    If we have a constraint like T <: List[S], we say that T depends on S, since
    we will need to solve for S first before we can solve for T.
    )r`   r9   rc   r_   )
r°   re   rM   rN   rP   rB   Údepsr�   r‚   Úothers
             rR   r^   r^   î  s¸   € ð €CØò ˆÜ‹uˆØ˜‘*ò 	(ˆBØ”H˜R Ó'Ñ'‰Dð	(à˜‘*ò 	(ˆBØ”H˜R Ó'Ñ'‰Dð	(àò 	 ˆEØ˜Š{ØØ�Eˆ{˜eÑ#¨¨r {°eÒ';Ø—‘˜•ð		 ô
 �t“*ˆˆBŠðð €Jrv   c                óx   ‡ — ‰ D ]4  }t        ˆ fd„||   D «       «      r yt        ˆ fd„||   D «       «      sŒ4 y y)z•Check there are only linear constraints between type variables in SCC.

    Linear are constraints like T <: S (while T <: F[S] are non-linear).
    c              3  óH   •K  — | ]  }t        |t        ‰«      «      –— Œ y ­wrV   ©r9   r_   )rX   r�   rY   s     €rR   rZ   zcheck_linear.<locals>.<genexpr>  ó   øè ø€ Ò<¨2Œx˜œD ›I×&Ñ<ùó   ƒ"Fc              3  óH   •K  — | ]  }t        |t        ‰«      «      –— Œ y ­wrV   r¼   )rX   r‚   rY   s     €rR   rZ   zcheck_linear.<locals>.<genexpr>  r½   r¾   T)Úany)rY   rM   rN   rB   s   `   rR   rW   rW     sC   ø€ ð
 ò ˆÜÓ<°¸±Ô<Ô<ÙÜÓ<°¸±Ô<Õ<Ùð	ð
 rv   c           
     ó"  — t        «       }| D ]ç  }t        |j                  «      }t        |t        «      sŒ)|j
                  D ]°  }t        |t        «      sŒ||j                  k(  r%|j                  t        k(  r|j                  |«       ŒH|j                  t        |t        |j                  «      |j                  «      «       |j                  t        |j                  |j                  |«      «       Œ² Œé | D �cg c]	  }||vsŒ|‘Œ c}S c c}w )a?  Avoid ambiguities for constraints inferred from unions during polymorphic inference.

    Polymorphic inference implicitly relies on assumption that a reverse of a linear constraint
    is a linear constraint. This is however not true in presence of union types, for example
    T :> Union[S, int] vs S <: T. Trying to solve such constraints would be detected ambiguous
    as (T, S) form a non-linear SCC. However, simply removing the linear part results in a valid
    solution T = Union[S, int], S = <free>. A similar scenario is when we get T <: Union[T, int],
    such constraints carry no information, and will equally confuse linearity check.

    TODO: a cleaner solution may be to avoid inferring such constraints in first place, but
    this would require passing around a flag through all infer_constraints() calls.
    )r`   r&   r7   r‡   r$   r5   r"   r¨   r6   r   rc   r
   r   )rL   Úreverse_union_csrF   Úp_targetr«   s        rR   r1   r1     sä   € ô “uÐØò TˆÜ" 1§8¡8Ó,ˆÜ�h¤	Õ*Ø Ÿ™ò T�Ü˜d¤KÕ0Ø˜q×0Ñ0Ò0°Q·T±T¼ZÒ5GØ(×,Ñ,¨QÔ/Ø ð %×(Ñ(¬°D¼&ÀÇÁ»,È×HYÑHYÓ)ZÔ[Ø$×(Ñ(¬°A×4EÑ4EÀqÇtÁtÈTÓ)RÕSñTðTð Ö7�!˜QÐ&6Ò6ŠAÒ7Ð7ùÒ7s   Ã;	DÄDc                ój   — t        | «      D �ch c]  }|j                  ’Œ c}t        |«      z  S c c}w )z>Find type variables for which we are solving in a target type.)r   r-   r`   )r7   rC   rB   s      rR   r9   r9   0  s(   € ä-¨fÓ5Ö6�bˆB�E‹EÒ6¼¸T»ÑBÐBùÒ6s   Ž0c                óþ  — g }t        || «      D ]ë  \  }}t        |j                  «      r|j                  |«       Œ-|�¬t	        ||j                  «      s–d}|D ]q  }|j
                  t        k(  r$t	        |j                  |j                  «      sd} n:|j
                  t        k(  sŒNt	        |j                  |j                  «      rŒod} n |r|j                  |j                  «       ŒÛ|j                  |«       Œí |S )zçCheck is each solution satisfies the upper bound of the corresponding type variable.

    If it doesn't satisfy the bound, check if bound itself satisfies all constraints, and
    if yes, use it instead as a fallback solution.
    TF)	ÚzipÚis_callable_protocolr™   r3   r   r6   r   r7   r	   )rJ   r=   r>   Únew_solutionsrˆ   r   Úbound_satisfies_allrF   s           rR   r<   r<   5  så   € ð (*€MÜ�M 9Ó-ò  ‰ˆˆ1Ü §¡Ô.ð × Ñ  Ô#ØØˆ=¤¨A¨q¯}©}Ô!=Ø"&ÐØ ò �Ø—4‘4œ:Ò%¬j¸¿¹ÈÏÉÔ.QØ*/Ð'ÙØ—4‘4œ<Ó'´
¸1¿8¹8ÀQÇ]Á]Õ0SØ*/Ð'Ùðñ #Ø×$Ñ$ Q§]¡]Ô3ØØ×Ñ˜QÕð% ð& Ðrv   c                ó–   — t        | «      }t        |t        «      r.|j                  j                  rd|j                  j
                  v S y)NÚ__call__F)r&   r‡   r   r£   Úis_protocolÚprotocol_members)rˆ   Úproper_ts     rR   rÇ   rÇ   V  s:   € Ü˜qÓ!€HÜ�(œHÔ%¨(¯-©-×*CÒ*CØ˜XŸ]™]×;Ñ;Ð;Ð;Ørv   N)TFF)r=   úSequence[TypeVarLikeType]r>   úlist[Constraint]r?   Úboolr@   rÑ   rA   rÑ   Úreturnz/tuple[list[Type | None], list[TypeVarLikeType]])
rC   úlist[TypeVarId]r>   rÐ   r=   rÓ   rD   z dict[TypeVarId, TypeVarLikeType]rÒ   z'tuple[Solutions, list[TypeVarLikeType]])
rn   rÓ   re   r*   rM   r)   rN   r)   rÒ   r+   )rˆ   r   rÒ   Úint)rM   úIterable[Type]rN   rÕ   rÒ   zType | None)rY   zlist[TypeVarLikeType]r=   rÓ   rÒ   zTypeVarLikeType | None)F)r¦   r   rš   rÑ   rÒ   rÑ   )rF   r
   rÒ   ztuple[bool, TypeVarId | None])r°   rÓ   r>   rÐ   rÒ   ztuple[Graph, Bounds, Bounds])rL   zset[Constraint]r´   r   rµ   r   rÒ   ÚNone)
r°   rÓ   re   r*   rM   r)   rN   r)   rÒ   z dict[TypeVarId, list[TypeVarId]])rY   úset[TypeVarId]rM   r)   rN   r)   rÒ   rÑ   )rL   rÐ   rÒ   rÐ   )r7   r   rC   rÓ   rÒ   r×   )rJ   úlist[Type | None]r=   rÏ   r>   rÐ   rÒ   rØ   )rˆ   r   rÒ   rÑ   )HÚ__doc__Ú
__future__r   Úcollectionsr   Úcollections.abcr   r   Útypingr   r(   Úmypy.constraintsr   r	   r
   r   r   Úmypy.expandtyper   Úmypy.graph_utilsr   r   r   Ú	mypy.joinr   Ú	mypy.meetr   r   Úmypy.subtypesr   Úmypy.typeopsr   Ú
mypy.typesr   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   Úmypy.typestater'   r)   Ú__annotations__r*   r+   rS   r4   rd   r‰   r8   rb   rœ   r¬   r]   r¯   r^   rW   r1   r9   r<   rÇ   r\   rv   rR   ú<module>rè      sæ  ðÚ 'å "å #ß .Ý *ç \Õ \Ý 'ß QÑ QÝ $ß 0Ý $Ý *÷÷ ÷ ÷ õ õ& &à1€ˆ
Ó 1Ø6€€zÓ 6Ø6€	ˆ:Ó 6ð Ø#Ø"ðUØ,ðUà!ðUð ðUð ð	Uð
 ðUð 5óUðp:?Ø
ð:?à!ð:?ð #ð:?ð 0ð	:?ð
 -ó:?ðz9Øð9Ø#(ð9Ø28ð9ØBHð9àó9óx	óBðJ0Ø	ð0Ø/>ð0àó0ôfNóð"G!ØðG!Ø)9ðG!à!óG!óTBðØðØ#(ðØ28ðØBHðà%óó0
ó8ó:Cð
Ø ðà,ðð "ðð ó	ôBrv   