
    Mh(                         d dl mZ d dl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 d dlmZ d dlmZ d	 Z G d
 de          Zd Zd Zd ZdS )    )defaultdict)	Parameter)debug)PushBackIterator)analysis)LazyKnownValueLazyTreeValueLazyUnknownValue)iterable)	ParamNamec                     t          |t                    r:|j        }|j        j        dk    r|j        }t          j        |j        | ||          S d S )Nargument)
isinstancer	   dataparenttyper   addcontext)
error_name
lazy_valuemessagenodes       T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jedi/inference/param.py_add_argument_issuer      sX    *m,, K;z));D|J.
D'JJJ	K K    c                   2     e Zd Zd fd	Zd Zd Zd Z xZS )ExecutedParamNameFc                 v    t                                          ||j        |           || _        || _        d S )N)	arguments)super__init__name_lazy_value_is_default)selffunction_valuer   
param_noder   
is_default	__class__s         r   r!   zExecutedParamName.__init__   s:    INNN%%r   c                 4    | j                                         S N)r#   inferr%   s    r   r,   zExecutedParamName.infer   s    %%'''r   c                 ^   | j         rdS |                                                                 }|                                 t          j        t          j        fv rdS |                     d          sdS t          fd|D                       }t          j
        d||d           |S )NTF)execute_annotationc              3   p   K   | ]0}                                 D ]}|                    |          V  1d S r+   )gather_annotation_classesis_sub_class_of).0c1c2annotationss      r   	<genexpr>z6ExecutedParamName.matches_signature.<locals>.<genexpr>)   sq       I I + E E G GI I ((,, I I I I I I Ir   zparam compare %s: %s <=> %sBLUE)color)r$   r,   py__class__get_kindr   VAR_POSITIONALVAR_KEYWORDinfer_annotationanyr   dbg)r%   argument_valuesmatchesr6   s      @r   matches_signaturez#ExecutedParamName.matches_signature   s     	4**,,2244==??y79NOOO4++u+EE 	 4 I I I I /I I I I I 		/?Kv	G 	G 	G 	Gr   c                 2    d| j         j        d| j        dS )N<z: >)r)   __name__string_namer-   s    r   __repr__zExecutedParamName.__repr__0   s#     !^444d6F6F6FGGr   )F)rG   
__module____qualname__r!   r,   rC   rI   __classcell__)r)   s   @r   r   r      sq        & & & & & &
( ( (  $H H H H H H Hr   r   c           
      >	   fd}g g }i }| j         |                                 }                                D ]}|||j        j        <   t                                                  t          t                              }t          d           }i }	d}
d}                                D ]}d}t          |d          \  }}|d}
	 ||         }||	v r]d}dj        d|d	}                                D ]7}                    t          j        |j        d
|j        |                     8n+t#          | ||          |	|<   n# t$          $ r |||<   Y nw xY wt          |d          \  }}|	 |                    |	|j        j                            # t$          $ r Y nw xY w|j        dk    r{g }|M|                    |           |D ]5\  }}|r|                    ||f            n|                    |           6t+          j        | j        |          }t1          |          }n|j        dk    rF| ||           t+          j        | j        t5          |                    }t1          |          }i }n||j        zt9                      }|
si                                D ]T}t;          t=                              }                    t          j        |j        d|j        |                     Unt?          ||j                  }d}n|}|                    t#          | |||                     tA          |t8                    s|d         |	|j        j        <   |
rtC          |          tC          |	          z
  D ]}||         }|sy|sw|j        sp|j        si                                D ]T}t;          t=                              }                    t          j        |j        d|j        |                     U|"                                D ]8\  }}dj        d|d	}                    tG          d||                     9t          |          }|r|d         \  }} ||           |fS )a  
    Return a tuple of:
      - a list of `ExecutedParamName`s corresponding to the arguments of the
        function execution `function_value`, containing the inferred value of
        those arguments (whether explicit or default)
      - a list of the issues encountered while building that list

    For example, given:
    ```
    def foo(a, b, c=None, d='d'): ...

    foo(42, c='c')
    ```

    Then for the execution of `foo`, this will return a tuple containing:
      - a list with entries for each parameter a, b, c & d; the entries for a,
        c, & d will have their values (42, 'c' and 'd' respectively) included.
      - a list with a single entry about the lack of a value for `b`
    c                    t          t                              }                                r'                    t	          d| |                     d S                     d            t          j        d|           d S )Nztype-error-too-many-argumentsr   znon-public warning: %s)_error_argument_countlenget_calling_nodesappendr   r   warning)r   mr   funcdefissuesunpacked_vas     r   too_many_argsz:get_executed_param_names_and_issues.<locals>.too_many_argsH   s    !'3{+;+;<< &&(( 	7MM#3       MM$M2A66666r   c                      g S r+    r[   r   r   <lambda>z5get_executed_param_names_and_issues.<locals>.<lambda>g   s    B r   F)NNNTTypeError: z-() got multiple values for keyword argument 'z'.ztype-error-multiple-valuesrO         ztype-error-too-few-arguments)r(   z'() got an unexpected keyword argument 'ztype-error-keyword-argumentr   )$	tree_nodeget_default_param_context
get_paramsr"   valuelistunpackr   iterr   nextrR   rS   r   r   r   r   r   KeyError
star_count	push_backr   	FakeTupleinference_stater   FakeDictdictdefaultr
   rP   rQ   r	   r   setitemsr   )r&   r   rY   result_params
param_dictdefault_param_contextparamvar_arg_iteratornon_matching_keys	keys_used	keys_onlyhad_multiple_value_errorr(   keyr   	key_paramrU   contextualized_nodelazy_value_listseq
result_argdctkr   remaining_arguments	first_keyrV   rW   rX   s    `                        @@@r   #get_executed_param_names_and_issuesr   4   s   (7 7 7 7 7 7 7 7" FMJ&G +DDFF##%% - -',
5:#$$y''0011K'[(9(9::#JJ//II$##%% R< R<
 
-|<<XoIH&sO	 )##/3,,#LLL###/A/8/J/J/L/L  +$L)<)D)E)<)A1N N N    &7&	9h&H &HIcNN  2 2 2)1!#&&&2  !!1<@@MC) o,	  5:+;!<=== 	 	 	D	 q   O#&&x000%5 5 5MC (22C?CCC#**84444$^%C_UUC',,JJ""#h'''#N$BDIZD[D[\\C',,J " =(!1!3!3J$ 
3<3N3N3P3P 	 	/ 5gs;?O?O P PA"MM ($7$?$B$7$<,-	!" !" !"    "//Dem!T!TJ!%JJ%
.IujZ
 
 
 	 	 	 *&677 	<*7*;Iej&'  Z3y>>1 	 	AqME% 	)A 	'	+0=	 ,5+F+F+H+H  '-gs;7G7GHHAMM %8%@%C%8%=qJ J J    -2244 	
 	
ZZ|||SSS"-  	
 	
 	
 	
 /00 " 3A 6	:j!!!&  s$   EE*)E*%F))
F65F6c                 .    t          | |          d         S )a|  
    Return a list of `ExecutedParamName`s corresponding to the arguments of the
    function execution `function_value`, containing the inferred value of those
    arguments (whether explicit or default). Any issues building this list (for
    example required arguments which are missing in the invocation) are ignored.

    For example, given:
    ```
    def foo(a, b, c=None, d='d'): ...

    foo(42, c='c')
    ```

    Then for the execution of `foo`, this will return a list containing entries
    for each parameter a, b, c & d; the entries for a, c, & d will have their
    values (42, 'c' and 'd' respectively) included.
    r   )r   )r&   r   s     r   get_executed_param_namesr      s    $ /~yII!LLr   c                     |                                  }t          d |D                       }|dk    rd}ndt          |          |z
  z  }d| j        d|t          |          d|dS )	Nc              3   6   K   | ]}|j         s|j        d V  dS )r^   N)rp   rj   )r3   ps     r   r7   z(_error_argument_count.<locals>.<genexpr>   s0      KK!KalKAKKKKKKr   r   zexactly zfrom %s to r]   z	() takes z arguments (z given).)rc   sumrQ   r"   )rV   actual_countparamsdefault_argumentsbefores        r   rP   rP      s    !!FKKvKKKKKA#f++0A"AB|||VVS[[[[,,,@ Ar   N)collectionsr   inspectr   jedir   jedi.inference.utilsr   jedi.inferencer   jedi.inference.lazy_valuer   r	   r
   jedi.inference.valuer   jedi.inference.namesr   r   r   r   r   rP   r[   r   r   <module>r      s<   # # # # # #             1 1 1 1 1 1 # # # # # #$ $ $ $ $ $ $ $ $ $ ) ) ) ) ) ) * * * * * *K K KH H H H H	 H H H>l! l! l!^M M M*	A 	A 	A 	A 	Ar   