
    MhS                        d Z ddlmZ ddlmZ ddlmZ dedfdedfd	e	d
fde
dfde
dfde
dfde
dfde
dfde
dfde
dfde
dfde
dfde
dfdedfdedfdZ G d d          Z G d de          ZdedfdZd Zd Zd!d ZdS )"z
Module for statical analysis.
    )tree)debug)	is_string   zPotential AttributeError.   zPotential NameError.   zPotential ImportError.   N            	   
                  )attribute-errorz
name-errorzimport-errorztype-error-too-many-argumentsztype-error-too-few-argumentsztype-error-keyword-argumentztype-error-multiple-valuesztype-error-star-starztype-error-starztype-error-operationztype-error-not-iterableztype-error-isinstanceztype-error-not-subscriptablezvalue-error-too-many-valueszvalue-error-too-few-valuesc                   v    e Zd ZddZed             Zed             Zed             Zd Zd Z	d Z
d	 Zd
 ZdS )ErrorNc                 r    || _         || _        || _        |t          | j                 d         }|| _        d S )Nr   )path
_start_posnameCODESmessage)selfr   module_path	start_posr   s        W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jedi/inference/analysis.py__init__zError.__init__   s8    	#	?DI&q)G    c                     | j         d         S Nr   r   r   s    r!   linez
Error.line&       q!!r#   c                     | j         d         S )Nr   r&   r'   s    r!   columnzError.column*   r)   r#   c                 v    | j         j        d         }|t          t          | j                 d                   z   S r%   )	__class____name__strr   r   )r   firsts     r!   codez
Error.code.   s2     '*s5+A.////r#   c           	      T    | j         d| j        d| j        d| j        d| j        	S )N::  )r   r(   r+   r1   r   r'   s    r!   __str__zError.__str__4   s4    $(IIItyyy$+++$(IIIt||= 	=r#   c                 b    | j         |j         k    o| j        |j        k    o| j        |j        k    S N)r   r   r   r   others     r!   __eq__zError.__eq__8   s5    	UZ' 8DI,C 8Ou'77	9r#   c                 .    |                      |           S r8   )r;   r9   s     r!   __ne__zError.__ne__<   s    ;;u%%%%r#   c                 D    t          | j        | j        | j        f          S r8   )hashr   r   r   r'   s    r!   __hash__zError.__hash__?   s    TY;<<<r#   c                 z    d| j         j        d| j        d| j        d| j        d         d| j        d         dS )	N<r5   r4   @r   ,r   >)r-   r.   r   r   r   r'   s    r!   __repr__zError.__repr__B   sN     &*n&=&=&=&*iii&*oa&8&8&8$/!:L:L:LN 	Nr#   r8   )r.   
__module____qualname__r"   propertyr(   r+   r1   r6   r;   r=   r@   rF    r#   r!   r   r      s            " " X" " " X" 0 0 X0
= = =9 9 9& & &= = =N N N N Nr#   r   c                       e Zd ZdS )WarningN)r.   rG   rH   rJ   r#   r!   rL   rL   H   s        Dr#   rL   c                 N   t           |         d         }t          | |||          rd S |                                 }|                                } ||||j        |          }	t          j        t          |	          d           | j        j	        
                    |	           |	S )Nr   F)format)r   _check_for_exception_catchget_root_context
py__file__r    r   warningr/   inference_stateanalysisappend)
node_context
error_namenoder   typpayload	exceptionmodule_contextr   issue_instances
             r!   addr^   L   s    j!!$I!,iII  "2244N ++--KS[$.'JJN	M#n%%e4444 )00@@@r#   c                     |                                  }|j        dS 	                                 d         }n# t          $ r Y dS w xY wt	          fd|D                       S )zU
    Check if there's any setattr method inside an instance. If so, return True.
    NFsetattrc              3      K   | ]D}j         |j         cxk     o
j        k     nc o |j        j        d k    o|j        j        |k     V  EdS )funcdefN)r    end_posparenttyper   ).0nrX   s     r!   	<genexpr>z%_check_for_setattr.<locals>.<genexpr>i   s~       $ $  ~::::dl:::: K2Iqx}7IJ$ $ $ $ $ $r#   )rP   	tree_nodeget_used_namesKeyErrorany)instancemodule
stmt_namesrX   s      @r!   _check_for_setattrrp   Z   s     &&((FD|u((**95

   uu  $ $ $ $ #$ $ $ $ $ $s   = 
A
Ac                     d|d|d}t           }|                                r*|                                st          |          rt          }||f}t          | d||||           d S )NzAttributeError: z has no attribute .r   )r   is_instanceis_compiledrp   rL   r^   )name_contextlookup_valuer   r   rY   rZ   s         r!   add_attribute_errorrw   o   s     <HLL$$$OG C!! ,*B*B*D*D  l++ 	CD G'wWEEEEEr#   c                     d  fd} fd}}|t          |t          j        t          j        f          st          |t          j                  rQ|j        dk    r |||          rdS |t          k    r-|j        dv r$ ||j        d         |j        d	                   rdS |j        }|&t          |t          j        t          j        f          d
S )a  
    Checks if a jedi object (e.g. `Statement`) sits inside a try/catch and
    doesn't count as an error (if equal to `exception`).
    Also checks `hasattr` for AttributeErrors and uses the `payload` to compare
    it.
    Returns True if the exception was catched.
    c                     |                                  sdS |                                D ];}|                                 |j        k    r| j                                        r dS <dS )NFT)is_classmro
py__name__r.   parent_contextis_builtins_module)clsr[   
python_clss      r!   check_matchz/_check_for_exception_catch.<locals>.check_match   sj    ||~~ 	5#--// 	 	J~~:#666*==?? 7ttur#   c                    t          | j                  }|D ]G}t          |           t          |          }|dk    r!|j        j        cxk     r|j        k    sn  dS H|                                 D ]}| dS                     |          }|D ]y}ddlm} t          ||j
                  rL|j        dk    rA|                                D ]+}	|	                                D ]}
 |
|          r    dS ,i ||          r  dS zd S )NtryFTr   )iterabletuple)iterchildrennextr    rc   get_except_clause_tests
infer_nodejedi.inference.valuer   
isinstanceSequence
array_type
py__iter__infer)objr[   iteratorbranch_typesuiterX   except_classesr   r   
lazy_valuerY   r   	jedi_namerV   s              r!   check_try_for_exceptz8_check_for_exception_catch.<locals>.check_try_for_except   s   %%# 	 	KNNNNNEe##(2Y5HYYYYEMYYYYuu//11 	( 	(D|tt!-!8!8!>!>) ( (C======!#x'899 	(Ng55*-..*:*: 0 0J'1'7'7'9'9 0 0#.;sI#>#> !0+/44444!000
 ';sI66 (#'444((	( 	(r#   c                     	 |j         j         cxk    r|j        k     sn J | j        dv sJ | j        d         }|j        dk    r|j        dk    sJ | j        d         }|j        dk    sJ |j        d         }|j        dk    sJ ddlm}  |j        |          }t          |	                                          }t          |          d	k    sJ |d         \  }}	t          |	                                          }
t          |
          dk    rt          |
d                   sJ |
d                                         d         j        k    sJ |d         \  }}	|	                                }d         |v S # t          $ r Y d
S w xY w)N)power	atom_exprr   r   hasattrr   trailerarglist)TreeArgumentsr   F)r    rc   re   r   valuejedi.inference.argumentsr   rS   listunpacklenr   r   get_safe_valueAssertionError)rX   r   baser   r   r   argsunpacked_argskeyr   namesobjectsr   rV   rZ   s               r!   check_hasattrz1_check_for_exception_catch.<locals>.check_hasattr   s   	?i&9IIIIEMIIIIII9 66666=#D9&&4:+B+B+B+BmA&G<9,,,,&q)G<9,,,,>>>>>> =!=|WUUD //M}%%**** ,A.OC))++,,Eu::??yq':':???8**,,
0@@@@@ ,A.OC &&((G1:(( 	 	 	55	s   E;E? ?
FFNtry_stmtT)if_stmt
while_stmtr   r   F)	r   r   FunctionClassFlowre   AttributeErrorr   rd   )rV   r   r[   rZ   r   r   r   r   s   `` `   @r!   rO   rO   ~   s      ( ( ( ( ( ( (8      : C
/*S4=$*2M"N"N/c49%% 	 x:%%*>*>sI*N*N%tN**sx;T/T/T =a#,q/BB  4j /*S4=$*2M"N"N/ 5r#   r8   )__doc__parso.pythonr   jedir   jedi.inference.helpersr   r   	NameErrorImportError	TypeError
ValueErrorr   r   rL   r^   rp   rw   rO   rJ   r#   r!   <module>r      s                , , , , , , >+FGi!78%=>&'D%9%&	4$8$%y$#7#$i"6	409d+D1 "It4 )T2%'D$9$&
D#9#%z4"8	 	&(N (N (N (N (N (N (N (NV	 	 	 	 	e 	 	 	 15%    $ $ $*F F FW W W W W Wr#   