Format: application/x-python-code
⬇ Download File (6.8 KB)
   1  o
   2  
   3  �h�(�@s�ddlmZddlmZddlmZddlmZddlm	Z	ddl
   4  mZmZm
   5  Z
   6  ddlmZddlmZd	d
   7  �ZGdd�de�Zd
   8  d�Zdd�Zdd�ZdS)�)�defaultdict)�	Parameter)�debug)�PushBackIterator)�analysis)�LazyKnownValue�
   9  LazyTreeValue�LazyUnknownValue)�iterable)�	ParamNamecCs8t|t�r|j}|jjdkr|j}t�|j|||�SdS)N�argument)�
  10  isinstancer�data�parent�typer�add�context)Z
  11  error_name�
  12  lazy_value�message�node�r�Jc:\Users\shubh\Videos\agent\nova\Lib\site-packages\jedi/inference/param.py�_add_argument_issue
  13  s
  14  �rcs6eZdZd
  15  �fdd�	Zdd�Zdd�Zdd	�Z�ZS)�ExecutedParamNameFcs$t�j||j|d�||_||_dS)N)�	arguments)�super�__init__�name�_lazy_value�_is_default)�self�function_valuerZ
  16  param_noder�
  17  is_default��	__class__rrrs
  18  zExecutedParamName.__init__cCs
  19  |j��S�N)r�infer�r rrrr&s
  20  zExecutedParamName.infercsp|jrdS|����}|��tjtjfvrdS|jdd���s!dSt�fdd�|D��}t	j
  21  d||�dd�|S)	NTF)Zexecute_annotationc3s(�|]}���D]}|�|�VqqdSr%)Zgather_annotation_classesZis_sub_class_of)�.0�c1�c2��annotationsrr�	<genexpr>)s���z6ExecutedParamName.matches_signature.<locals>.<genexpr>zparam compare %s: %s <=> %sZBLUE)�color)rr&Zpy__class__Zget_kindr�VAR_POSITIONAL�VAR_KEYWORDZinfer_annotation�anyrZdbg)r Zargument_values�matchesrr+r�matches_signatures��z#ExecutedParamName.matches_signaturecCsd|jj|jfS)Nz<%s: %s>)r$�__name__Zstring_namer'rrr�__repr__0szExecutedParamName.__repr__)F)r4�
  22  __module__�__qualname__rr&r3r5�
  23  __classcell__rrr#rrs
  24  rc
  25  s�����fdd�}g�g}i}|j�|��}���D]}|||jj<qt������tt���}t	dd��}i}	d}
  26  d}���D�]}d}t
  27  |d�\}
  28  }|
  29  dur�d}
  30  z||
  31  }Wn
  32  tye|||
  33  <Yn-w|
  34  |	vr�d}d	�j|
  35  f}���D]}��
  36  tj|jd
  37  |j|d��qwn	t|�||�|	|
  38  <t
  39  |d�\}
  40  }|
  41  dusPz|�
  42  |	|jj�Wq@ty�Ynw|jdkr�g}|dur�|�
  43  |�|D]\}
  44  }|
  45  r�|�|
  46  |f�n|�
  47  |�q�t�|j|�}t|�}nX|jd
  48  k�r|dur�||�t�|jt|��}t|�}i}n:|du�r;|jdu�r2t�}|
  49  �s1���D]}t�t���}��
  50  tj|jd|j|d���qnt||j�}d}n|}|�
  51  t|�|||d��t |t��sW|d|	|jj<q@|
  52  �r�t!|�t!|	�D]2}||}|�s�|�s�|j�s�|j�s����D]}t�t���}��
  53  tj|jd|j|d���q{�qc|�"�D]\}
  54  }d�j|
  55  f}��
  56  t#d||d���q�t|�}|�r�|d\}}||�|�fS)a�
  57      Return a tuple of:
  58        - a list of `ExecutedParamName`s corresponding to the arguments of the
  59          function execution `function_value`, containing the inferred value of
  60          those arguments (whether explicit or default)
  61        - a list of the issues encountered while building that list
  62  
  63      For example, given:
  64      ```
  65      def foo(a, b, c=None, d='d'): ...
  66  
  67      foo(42, c='c')
  68      ```
  69  
  70      Then for the execution of `foo`, this will return a tuple containing:
  71        - a list with entries for each parameter a, b, c & d; the entries for a,
  72          c, & d will have their values (42, 'c' and 'd' respectively) included.
  73        - a list with a single entry about the lack of a value for `b`
  74      csHt�t���}���r��td||d��dS��d�t�d|�dS)Nztype-error-too-many-arguments�rznon-public warning: %s)�_error_argument_count�len�get_calling_nodes�appendrr�warning)r�m�r�funcdefZissuesZunpacked_varr�
  75  too_many_argsHs��
  76  z:get_executed_param_names_and_issues.<locals>.too_many_argscSsgSr%rrrrr�<lambda>gsz5get_executed_param_names_and_issues.<locals>.<lambda>F)NNNTz>TypeError: %s() got multiple values for keyword argument '%s'.ztype-error-multiple-valuesr9��ztype-error-too-few-arguments)r"�����z8TypeError: %s() got an unexpected keyword argument '%s'.ztype-error-keyword-argumentr)$Z	tree_nodeZget_default_param_context�
  77  get_paramsr�value�list�unpackr�iterr�next�KeyErrorr<r=rrrrr�
  78  star_countZ	push_backr
  79  Z	FakeTupleZinference_staterZFakeDict�dict�defaultr	r:r;rr
  80  �set�itemsr)r!rrBZ
  81  result_paramsZ
  82  param_dictZdefault_param_context�paramZvar_arg_iteratorZnon_matching_keysZ	keys_usedZ	keys_onlyZhad_multiple_value_errorr"�keyrZ	key_paramr?Zcontextualized_nodeZlazy_value_list�seqZ
  83  result_arg�dct�krZremaining_argumentsZ	first_keyrr@r�#get_executed_param_names_and_issues4s���������
  84  
  85  
  86  
  87  ���	
  88  ����������rXcCst||�dS)a|
  89      Return a list of `ExecutedParamName`s corresponding to the arguments of the
  90      function execution `function_value`, containing the inferred value of those
  91      arguments (whether explicit or default). Any issues building this list (for
  92      example required arguments which are missing in the invocation) are ignored.
  93  
  94      For example, given:
  95      ```
  96      def foo(a, b, c=None, d='d'): ...
  97  
  98      foo(42, c='c')
  99      ```
 100  
 101      Then for the execution of `foo`, this will return a list containing entries
 102      for each parameter a, b, c & d; the entries for a, c, & d will have their
 103      values (42, 'c' and 'd' respectively) included.
 104      r)rX)r!rrrr�get_executed_param_names�srYcCsN|��}tdd�|D��}|dkrd}ndt|�|}d|j|t|�|fS)Ncss �|]}|js
 105  |jrdVqdS)rDN)rPrN)r(�prrrr-�s�z(_error_argument_count.<locals>.<genexpr>rzexactly zfrom %s to z0TypeError: %s() takes %s%s arguments (%s given).)rG�sumr;r)rAZactual_count�paramsZdefault_arguments�beforerrrr:�s�r:N)�collectionsr�inspectrZjedirZjedi.inference.utilsrZjedi.inferencerZjedi.inference.lazy_valuerrr	Zjedi.inference.valuer
 106  Zjedi.inference.namesrrrrXrYr:rrrr�<module>s0