Format: application/x-python-code
⬇ Download File (6.7 KB)
   1  o
   2  
   3  �hS�@s�dZddlmZddlmZddlmZdedfdedfd	e	d
   4  fde
   5  dfd
   6  e
   7  dfde
   8  dfde
   9  dfde
  10  dfde
  11  dfde
  12  dfde
  13  dfde
  14  dfde
  15  dfdedfdedfd�ZGdd�d�Z
  16  Gdd�de
  17  �Zde
  18  dfdd�Zdd �Zd!d"�Zd%d#d$�ZdS)&z
  19  Module for statical analysis.
  20  �)�tree)�debug)�	is_string�zPotential AttributeError.�zPotential NameError.�zPotential ImportError.�N�����	�
  21  ���
  22  ��)�attribute-errorz
  23  name-errorzimport-errorztype-error-too-many-argumentsztype-error-too-few-argumentsztype-error-keyword-argumentztype-error-multiple-valuesztype-error-star-starztype-error-starztype-error-operationztype-error-not-iterableztype-error-isinstanceztype-error-not-subscriptablezvalue-error-too-many-valueszvalue-error-too-few-valuesc@sbeZdZddd�Zedd��Zedd��Zedd	��Zd
  24  d�Zdd
  25  �Z	dd�Z
  26  dd�Zdd�ZdS)�ErrorNcCs2||_||_||_|durt|jd}||_dS)Nr)�path�
  27  _start_pos�name�CODES�message)�selfr�module_path�	start_posr�r�Mc:\Users\shubh\Videos\agent\nova\Lib\site-packages\jedi/inference/analysis.py�__init__s
  28  zError.__init__cC�
  29  |jdS�Nr�r�rrrr�line&�
  30  z
  31  Error.linecCr!)Nrr#r$rrr�column*r&zError.columncCs"|jjd}|tt|jd�Sr")�	__class__�__name__�strrr)r�firstrrr�code.sz
  32  Error.codecCsd|j|j|j|j|jfS)Nz%s:%s:%s: %s %s)rr%r'r,rr$rrr�__str__4s�z
  33  Error.__str__cCs$|j|jko|j|jko|j|jkS�N)rrr�r�otherrrr�__eq__8s
  34  �zError.__eq__cCs|�|�Sr.)r1r/rrr�__ne__<szError.__ne__cCst|j|j|jf�Sr.)�hashrrrr$rrr�__hash__?szError.__hash__cCs&d|jj|j|j|jd|jdfS)Nz<%s %s: %s@%s,%s>rr)r(r)rrrr$rrr�__repr__Bs�zError.__repr__r.)
  35  r)�
  36  __module__�__qualname__r �propertyr%r'r,r-r1r2r4r5rrrrrs
  37  
  38  
  39  
  40  rc@seZdZdS)�WarningN)r)r6r7rrrrr9Hsr9c
  41  Csbt|d}t||||�rdS|��}|��}||||j|�}	tjt|	�dd�|jj	�
  42  |	�|	S)NrF)�format)r�_check_for_exception_catch�get_root_contextZ
  43  py__file__rr�warningr*�inference_stateZanalysis�append)
  44  �node_contextZ
  45  error_name�noder�typ�payload�	exceptionZmodule_contextrZissue_instancerrr�addLsrEcsV|��}|j��dur
  46  dSz���d}Wn
  47  tyYdSwt�fdd�|D��S)zU
  48      Check if there's any setattr method inside an instance. If so, return True.
  49      NF�setattrc3sH�|]}�j|jko�jkno|jjdko|jj|kVqdS)ZfuncdefN)r�end_pos�parent�typer)�.0�n�rArr�	<genexpr>is��
  50  �z%_check_for_setattr.<locals>.<genexpr>)r<Z	tree_nodeZget_used_names�KeyError�any)�instance�moduleZ
  51  stmt_namesrrLr�_check_for_setattrZs��rRcCsJd||f}t}|��r|��st|�rt}||f}t|d||||�dS)Nz'AttributeError: %s has no attribute %s.r)rZis_instanceZis_compiledrRr9rE)Zname_contextZlookup_valuerrrBrCrrr�add_attribute_errorosrScs�dd�����fdd�}���fdd�}�}|dur[t|tjtjf�s[t|tj�rK|jdkr5|||�r5d	S|tkrK|jd
  52  vrK||jd|jd�rKd	S|j}|dur[t|tjtjf�r#d
  53  S)a
  54      Checks if a jedi object (e.g. `Statement`) sits inside a try/catch and
  55      doesn't count as an error (if equal to `exception`).
  56      Also checks `hasattr` for AttributeErrors and uses the `payload` to compare
  57      it.
  58      Returns True if the exception was catched.
  59      cSs<|��sdS|��D]}|��|jkr|j��rdSq
  60  dS)NFT)�is_class�mroZ
  61  py__name__r)Zparent_contextZis_builtins_module)�clsrDZ
  62  python_clsrrr�check_match�s��z/_check_for_exception_catch.<locals>.check_matchcs�t|j�}|D]!}t|�t|�}|dkr(|j�jkr$|jks(dSdSq|��D]G}|dur6dS��|�}|D]6}ddlm}t	||j
  63  �rj|jdkrj|��D]}	|	�
  64  �D]
  65  }
  66  �|
  67  |�rgdSqZqTq=�||�rsdSq=q-dS)N�tryFTr)�iterable�tuple)�iter�children�nextrrGZget_except_clause_testsZ
  68  infer_nodeZjedi.inference.valuerY�
  69  isinstance�SequenceZ
  70  array_typeZ
  71  py__iter__�infer)�objrD�iteratorZbranch_type�suiterAZexcept_classesrVrY�
  72  lazy_valuerB)rW�	jedi_namer@rr�check_try_for_except�s<
  73  ��
  74  
  75  
  76  ���
  77  ���z8_check_for_exception_catch.<locals>.check_try_for_exceptcs>z�|j�jkr|jksJ�J�|jdvsJ�|jd}|jdkr(|jdks*J�|jd}|jdks6J�|jd}|jdksBJ�ddlm}|�j�|�}t|�	��}t
  78  |�d	ks]J�|d\}}	t|	���}
  79  t
  80  |
  81  �dkrut|
  82  d�swJ�|
  83  d�
  84  ��djks�J�|d\}}	|	��}�d|vWSty�Yd
  85  Sw)N)�powerZ	atom_exprrr�hasattrr�trailer�arglist)�
  86  TreeArgumentsrF)rrGrIr\�valueZjedi.inference.argumentsrkr>�list�unpack�lenr`rZget_safe_value�AssertionError)rArc�baserirjrk�argsZ
  87  unpacked_args�keyrd�names�objects)rer@rCrr�
  88  check_hasattr�s."
  89  
  90  
  91  �z1_check_for_exception_catch.<locals>.check_hasattrNZtry_stmtT)Zif_stmtZ
  92  while_stmtrrF)	r^r�Function�ClassZFlowrI�AttributeErrorr\rH)r@rerDrCrfrvrar)rWrer@rCrr;~s
  93  �r;r.)�__doc__Zparso.pythonrZjedirZjedi.inference.helpersrry�	NameError�ImportError�	TypeError�
  94  ValueErrorrrr9rErRrSr;rrrr�<module>s4�+