Ë
    pPêj˜,  ã                  óÜ   — d 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 ddlmZmZmZmZmZmZmZmZmZmZ erddlmZ 	 	 	 	 	 	 	 	 	 	 	 	 dd	„Z	 	 	 	 	 	 	 	 	 	 	 	 dd
„Z G d„ d«      Zy)zLUtilities for mapping between actual and formal arguments (and their types).é    )Úannotations)ÚCallableÚSequence)ÚTYPE_CHECKING)Únodes)Úmap_instance_to_supertype)
ÚAnyTypeÚInstanceÚParamSpecTypeÚ	TupleTypeÚTypeÚTypedDictTypeÚ	TypeOfAnyÚTypeVarTupleTypeÚ
UnpackTypeÚget_proper_type)ÚArgumentInferContextc                ó„  — t        |«      }t        |«      D �cg c]  }g ‘Œ }}g }d}	t        | «      D �]ñ  \  }
}|t        j                  k(  r_|	|k  sŒ ||	   j                  «       s||	   j                  |
«       |	dz  }	ŒM||	   t        j                  k(  sŒd||	   j                  |
«       Œy|t        j                  k(  rít         ||
«      «      }t        |t        «      rut        t        |j                  «      «      D ]R  }|	|k  sŒ	||	   t        j                  k7  r||	   j                  |
«       n �Œ||	   t        j                  k7  sŒN|	dz  }	ŒT �Œ"|	|k  s�Œ)||	   j                  d¬«      r�Œ@||	   j                  |
«       ||	   t        j                  k(  r�Œl|	dz  }	|	|k  rŒN�Œy|j                  «       r£|€J d«       ‚||
   }||v rJ||j                  |«         t        j                  k7  r%||j                  |«         j                  |
«       �Œåt        j                  |v s�Œù||j                  t        j                  «         j                  |
«       �Œ,|t        j                  k(  sJ ‚t         ||
«      «      }t        |t        «      r|j                  D ]n  }||v r$||j                  |«         j                  |
«       Œ+t        j                  |v sŒ>||j                  t        j                  «         j                  |
«       Œp �Œá|j                  |
«       �Œô |rŒt        |«      D �	cg c]V  }	||	   r7||	   r| ||	   d      t        j                  k(  r||	   t        j                  k7  s||	   t        j                  k(  r|	‘ŒX }}	|D ]  }
|D ]  }	||	   j                  |
«       Œ Œ |S c c}w c c}	w )a.  Calculate mapping between actual (caller) args and formals.

    The result contains a list of caller argument indexes mapping to each
    callee argument index, indexed by callee index.

    The actual_arg_type argument should evaluate to the type of the actual
    argument with the given index.
    r   é   T)Ústarz/Internal error: named kinds without names given)ÚlenÚrangeÚ	enumerater   ÚARG_POSÚis_starÚappendÚARG_STARr   Ú
isinstancer   ÚitemsÚ	ARG_STAR2Úis_namedÚindexr   )Úactual_kindsÚactual_namesÚformal_kindsÚformal_namesÚactual_arg_typeÚnformalsÚiÚformal_to_actualÚambiguous_actual_kwargsÚfiÚaiÚactual_kindÚactualtÚ_ÚnameÚunmatched_formalss                   úP/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/mypy/argmap.pyÚmap_actuals_to_formalsr4      s”  € ô �<Ó €HÜ5:¸8³_Ö(E°ªÐ(EÐÐ(EØ)+ÐØ	
€BÜ$ \Ó2ó 43‰ˆˆKØœ%Ÿ-™-Ò'Ø�H‹}Ø# BÑ'×/Ñ/Ô1Ø$ RÑ(×/Ñ/°Ô3Ø˜!‘G‘BØ! "Ñ%¬¯©Ó7Ø$ RÑ(×/Ñ/°Õ3ØœEŸN™NÒ*ä%¡o°bÓ&9Ó:ˆGÜ˜'¤9Ô-äœs 7§=¡=Ó1Ó2ò $�AØ˜H“}Ø'¨Ñ+¬u¯©Ò>Ø,¨RÑ0×7Ñ7¸Õ;â!Ø'¨Ñ+¬u¯~©~Ó=Ø !™G™Bò$ð ˜8”mØ# BÑ'×0Ñ0°dÐ0Ô;Ùà(¨Ñ,×3Ñ3°BÔ7Ø# BÑ'¬5¯>©>Ò9ÙØ˜!‘G�Bð ˜8•mð ×!Ñ!Ô#ØÐ+Ð^Ð-^Ó^Ð+Ø Ñ#ˆDØ�|Ñ#¨°\×5GÑ5GÈÓ5MÑ(NÔRW×R`ÑR`Ò(`Ø  ×!3Ñ!3°DÓ!9Ñ:×AÑAÀ"ÖEÜ—‘ LÓ0Ø  ×!3Ñ!3´E·O±OÓ!DÑE×LÑLÈRÖPà¤%§/¡/Ò1Ð1Ð1Ü%¡o°bÓ&9Ó:ˆGÜ˜'¤=Ô1Ø#ŸM™Mò Y�DØ˜|Ñ+Ø(¨×);Ñ);¸DÓ)AÑB×IÑIÈ"ÕMÜŸ™¨LÒ8Ø(¨×);Ñ);¼E¿O¹OÓ)LÑM×TÑTÐUWÕXò	Yð (×.Ñ.¨rÖ2ði43ñl ô ˜H“oö
àà˜RÒ à(¨Ò,Ø#Ð$4°RÑ$8¸Ñ$;Ñ<ÄÇÁÒNà  Ñ$¬¯©Ò6à˜BÑ¤5§?¡?Ò2ò ð
Ðð 
ð *ò 	0ˆBØ'ò 0�Ø  Ñ$×+Ñ+¨BÕ/ñ0ð	0ð Ðùò_ )Fùò|
s   ™	N8Ì7AN=c                ó¨   — t        | ||||«      }| D �cg c]  }g ‘Œ }}t        |«      D ]   \  }}	|	D ]  }
||
   j                  |«       Œ Œ" |S c c}w )z8Calculate the reverse mapping of map_actuals_to_formals.)r4   r   r   )r#   r$   r%   r&   r'   r*   r0   Úactual_to_formalÚformalÚactualsÚactuals              r3   Úmap_formals_to_actualsr:   }   sz   € ô .Ø�l L°,ÀóÐð 6BÖ(B°ªÐ(BÐÐ(BÜ$Ð%5Ó6ò 4‰ˆ�Øò 	4ˆFØ˜VÑ$×+Ñ+¨FÕ3ñ	4ð4ð Ðùò	 )Cs   ”	Ac                  ó:   — e Zd ZdZdd„Z	 d	 	 	 	 	 	 	 	 	 	 	 dd„Zy)ÚArgTypeExpandera  Utility class for mapping actual argument types to formal arguments.

    One of the main responsibilities is to expand caller tuple *args and TypedDict
    **kwargs, and to keep track of which tuple/TypedDict items have already been
    consumed.

    Example:

       def f(x: int, *args: str) -> None: ...
       f(*(1, 'x', 1.1))

    We'd call expand_actual_type three times:

      1. The first call would provide 'int' as the actual type of 'x' (from '1').
      2. The second call would provide 'str' as one of the actual types for '*args'.
      2. The third call would provide 'float' as one of the actual types for '*args'.

    A single instance can process all the arguments for a single call. Each call
    needs a separate instance since instances have per-call state.
    c                ó.   — d| _         d | _        || _        y )Nr   )Útuple_indexÚkwargs_usedÚcontext)Úselfr@   s     r3   Ú__init__zArgTypeExpander.__init__¦   s   € àˆÔà,0ˆÔàˆ�ó    c                ó´  — |}t        |«      }|t        j                  k(  �rÕt        |t        «      rt        |j
                  «      }t        |t        «      r|j                  rsddlm	}  ||| j                  j                  «      r7t        || j                  j                  j                  «      j                  d   S t        t        j                   «      S t        |t"        «      ræ| j$                  t'        |j(                  «      k\  rd| _        n| xj$                  dz  c_        |j(                  | j$                  dz
     }t        |t*        «      ry|swt        |j                  «      }	t        |	t        «      rt        |	j
                  «      }
n|	}
t        |
t        «      r|
j                  j,                  dk(  sJ ‚|
j                  d   }|S t        |t.        «      r|S t        t        j                   «      S |t        j0                  k(  �rMddlm	} t        |t2        «      r¨| j4                  €t7        «       | _        |t        j0                  k7  r||j(                  v r|€@J ‚t7        |j(                  j9                  «       «      | j4                  z
  j;                  «       }| j4                  j=                  |«       |j(                  |   S t        |t        «      rT ||| j                  j>                  «      r7t        || j                  j>                  j                  «      j                  d   S t        |t.        «      r|S t        t        j                   «      S |S )aù  Return the actual (caller) type(s) of a formal argument with the given kinds.

        If the actual argument is a tuple *args, return the next individual tuple item that
        maps to the formal arg.

        If the actual argument is a TypedDict **kwargs, return the next matching typed dict
        value type based on formal argument name and kind.

        This is supposed to be called for each formal, in order. Call multiple times per
        formal if multiple actuals map to a formal.
        r   )Ú
is_subtyper   zbuiltins.tuple) r   r   r   r   r   Úupper_boundr
   ÚargsÚmypy.subtypesrE   r@   Úiterable_typer   Útyper	   r   Ú
from_errorr   r>   r   r   r   Úfullnamer   r    r   r?   ÚsetÚkeysÚpopÚaddÚmapping_type)rA   Úactual_typer.   Úformal_nameÚformal_kindÚallow_unpackÚoriginal_actualrE   ÚitemÚunpackedÚfallbacks              r3   Úexpand_actual_typez"ArgTypeExpander.expand_actual_type®   s·  € ð& &ˆÜ% kÓ2ˆØœ%Ÿ.™.Ó(Ü˜+Ô'7Ô8ô .¨k×.EÑ.EÓF�Ü˜+¤xÔ0°[×5EÒ5EÝ4á˜k¨4¯<©<×+EÑ+EÔFÜ4Ø# T§\¡\×%?Ñ%?×%DÑ%Dóç‘d˜1ñð ô #¤9×#7Ñ#7Ó8Ð8Ü˜K¬Ô3à×#Ñ#¤s¨;×+<Ñ+<Ó'=Ò=à'(�DÕ$à×$Ò$¨Ñ)Õ$Ø"×(Ñ(¨×)9Ñ)9¸AÑ)=Ñ>�Ü˜d¤JÔ/¹ä.¨t¯y©yÓ9�HÜ! (Ô,<Ô=Ü#2°8×3GÑ3GÓ#H™à#+˜ä" 8¬XÔ6Ø$ŸM™M×2Ñ2Ð6FÒFððGð $Ÿ=™=¨Ñ+�DØ�Ü˜K¬Ô7à"Ð"äœy×3Ñ3Ó4Ð4ØœEŸO™OÓ+Ý0ä˜+¤}Ô5Ø×#Ñ#Ð+Ü'*£u�DÔ$Ø¤%§/¡/Ò1°kÀ[×EVÑEVÑ6Và&Ð2Ð2Ð2ô $' {×'8Ñ'8×'=Ñ'=Ó'?Ó#@À4×CSÑCSÑ#S×"XÑ"XÓ"Z�KØ× Ñ ×$Ñ$ [Ô1Ø"×(Ñ(¨Ñ5Ð5Ü˜K¬Ô2±zØ˜TŸ\™\×6Ñ6ô8ô
 1°¸d¿l¹l×>WÑ>W×>\Ñ>\Ó]×bÑbØñð ô ˜K¬Ô7à"Ð"äœy×3Ñ3Ó4Ð4ð #Ð"rC   N)r@   r   ÚreturnÚNone)F)rR   r   r.   únodes.ArgKindrS   z
str | NonerT   r]   rU   Úboolr[   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rB   rZ   © rC   r3   r<   r<   �   sW   „ ñó*ð #ð_#àð_#ð #ð_#ð  ð	_#ð
 #ð_#ð ð_#ð 
ô_#rC   r<   N)r#   úlist[nodes.ArgKind]r$   úSequence[str | None] | Noner%   rd   r&   zSequence[str | None]r'   úCallable[[int], Type]r[   úlist[list[int]])r#   rd   r$   re   r%   rd   r&   zlist[str | None]r'   rf   r[   rg   )rb   Ú
__future__r   Úcollections.abcr   r   Útypingr   Úmypyr   Úmypy.maptyper   Ú
mypy.typesr	   r
   r   r   r   r   r   r   r   r   Ú
mypy.inferr   r4   r:   r<   rc   rC   r3   ú<module>ro      s¼   ðÙ Rå "ç .Ý  å Ý 2÷÷ ÷ ñ Ý/ð_Ø%ð_à-ð_ð &ð_ð 'ð	_ð
 +ð_ð ó_ðDØ%ðà-ðð &ðð #ð	ð
 +ðð ó÷&}#ò }#rC   