
    fn,                        d Z ddl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 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mZ ddlmZmZ ddlmZ ddlmZm Z m!Z!  e"       Z# G d de      Z$ G d dee!      Z% G d de e%      Z& G d de      Z' G d dejP                        Z) e       d        Z*d Z+d Z, e       d        Z-y)z 
Used only for REPL Completion.
    N)Path)get_cached_code_lines)settings)memoize_method)compiled)FileIO)NameWrapper)ValueSetValueWrapper	NO_VALUES)ModuleValue)inference_state_function_cacheinference_state_method_cache)ALLOWED_GETITEM_TYPESget_api_type)to_stub)CompiledContextCompiledModuleContextTreeContextMixinc                        e Zd ZdZ fdZd Zd Z ee      d        Z	e
fdZed        Zd	 Zd
 Zd Zd Zd Z xZS )MixedObjecta  
    A ``MixedObject`` is used in two ways:

    1. It uses the default logic of ``parser.python.tree`` objects,
    2. except for getattr calls and signatures. The names dicts are generated
       in a fashion like ``CompiledValue``.

    This combined logic makes it possible to provide more powerful REPL
    completion. It allows side effects that are not noticable with the default
    parser structure to still be completable.

    The biggest difference from CompiledValue to MixedObject is that we are
    generally dealing with Python code and not with C code. This will generate
    fewer special cases, because we in Python you don't have the same freedoms
    to modify the runtime.
    c                 T    t         |   |       || _        |j                  | _        y N)super__init__compiled_valueaccess_handle)selfr   
tree_value	__class__s      X/var/www/cvtools/html/venv/lib/python3.12/site-packages/jedi/inference/compiled/mixed.pyr   zMixedObject.__init__,   s&    $,+99    c              /   f   K   t        | j                  | j                  | j                         y wr   )MixedObjectFilterinference_stater   _wrapped_value)r   argskwargss      r!   get_filterszMixedObject.get_filters1   s.       $"5"5t7J7JL 	Ls   /1c                 6    | j                   j                         S r   )r   get_signaturesr   s    r!   r+   zMixedObject.get_signatures5   s     ""1133r"   )defaultc                 j    t        | j                        }|s| j                  }|j                  |      S r   )r   r&   
py__call__)r   	argumentsvaluess      r!   r/   zMixedObject.py__call__:   s3     ,,-((F  ++r"   c                 |    |t         u r| j                  j                         S | j                  j                  |      S r   )	_sentinelr   get_safe_value)r   r-   s     r!   r4   zMixedObject.get_safe_valueB   s6    i&&5577&&55g>>r"   c                 .    | j                   j                  S r   )r   
array_typer,   s    r!   r6   zMixedObject.array_typeH   s    ""---r"   c                 6    | j                   j                         S r   )r   get_key_valuesr,   s    r!   r8   zMixedObject.get_key_valuesL   s    ""1133r"   c                     | j                   j                  j                  j                  }t	        |      t
        v r| j                   j                  |      S | j                  j                  |      S r   )r   r   access_objtyper   py__simple_getitem__r&   )r   indexpython_objects      r!   r=   z MixedObject.py__simple_getitem__O   s[    ++99@@EE"77&&;;EBB""77>>r"   c                 6    | j                   j                         S r   )r   negater,   s    r!   rA   zMixedObject.negateU   s    ""))++r"   c                 F    | j                   t        |       S t        |       S r   )parent_contextMixedModuleContextMixedContextr,   s    r!   _as_contextzMixedObject._as_contextX   s$    &%d++D!!r"   c                     dt        |       j                  d| j                  j                         d| j                  dS )N<z: z; >)r<   __name__r   get_reprr&   r,   s    r!   __repr__zMixedObject.__repr__]   s4    J'')
 	
r"   )rJ   
__module____qualname____doc__r   r)   r+   r   r   r/   r3   r4   propertyr6   r8   r=   rA   rF   rL   __classcell__r    s   @r!   r   r      sh     :
L4
 ")4, 5, &/ ? . .4?,"

r"   r   c                       e Zd Zed        Zy)rE   c                 .    | j                   j                  S r   )_valuer   r,   s    r!   r   zMixedContext.compiled_valuef   s    {{)))r"   N)rJ   rM   rN   rP   r    r"   r!   rE   rE   e   s    * *r"   rE   c                       e Zd Zy)rD   N)rJ   rM   rN   rV   r"   r!   rD   rD   k   s    r"   rD   c                   B     e Zd ZdZ fdZed        Zed        Z xZ	S )	MixedNamezB
    The ``CompiledName._compiled_value`` is our MixedObject.
    c                 2    t         |   |       || _        y r   )r   r   _parent_tree_value)r   wrapped_nameparent_tree_valuer    s      r!   r   zMixedName.__init__s   s    &"3r"   c                 l    t        | j                               }|sy|d   j                  j                  S )N)r   r   r   )listinfername	start_pos)r   r1   s     r!   rb   zMixedName.start_posw   s,    djjl#ay~~'''r"   c           	         | j                   j                         }| j                  }|j                         s|j	                         rN|j                  | j                        }|j                         r#t        |D ch c]  }t        ||       c}      S |j                         }t        | j                  ||      S c c}w r   )_wrapped_nameinfer_compiled_valuer[   is_instanceis_classpy__getattribute__string_nameis_functionr
   r   get_root_context_create_inference_state)r   r   r   tree_valuesvmodule_contexts         r!   r`   zMixedName.infer   s    ++@@B,,
!!#z':':'<$778H8HIK))+ UA^Q!? UVV#446t,,nnMM !Vs   ;B<)
rJ   rM   rN   rO   r   rP   rb   r   r`   rQ   rR   s   @r!   rY   rY   o   s7    4 ( ( 	N 	Nr"   rY   c                   (     e Zd Z fdZ fdZ xZS )r$   c                 4    t         |   ||       || _        y r   )r   r   _tree_value)r   r%   r   r   r    s       r!   r   zMixedObjectFilter.__init__   s    .9%r"   c                 J    t        t        |   |i || j                        S r   )rY   r   _create_namers   )r   r'   r(   r    s      r!   ru   zMixedObjectFilter._create_name   s+    G $1&1
 	
r"   )rJ   rM   rN   r   ru   rQ   rR   s   @r!   r$   r$      s    &
 
r"   r$   c                     | j                  |dt        j                  t        j                        j	                         S )NT)pathcache
diff_cache
cache_path)parser   fast_parsercache_directoryget_root_node)r%   rw   s     r!   _load_moduler      s;      ''++	 ! 
 mor"   c                    	 t        j                  |       } t        j                  |       s~t        j                  |       sit        j
                  |       sTt        j                  |       s?t        j                  |       s*t        j                  |       st        j                  |       r| S 	 | j                  S # t        $ r Y w xY w# t        $ r t        w xY w)z9Check if inspect.getfile has a chance to find the source.)inspectunwrap
ValueErrorismoduleisclassismethod
isfunctionistracebackisframeiscoder    AttributeError	TypeError)r?   s    r!   _get_object_to_checkr      s    }5
 	'}-.!!-0""=1}-~~m,&&&    s   B9 -C 9	CCCc                    |}	 t        |      }t        j                  |      }|d n
t        |      }	 ||j                         sy 	 t        |      }t        | |      }t        j                  |      rt        | j                  |      }||||fS 	 |j                  }|dk(  ry |j                         j                  |g       }|D 	cg c]5  }	|	j                   j"                  dv r|	j                   j$                  |	k(  r|	7 }}	|sy 	 |j&                  }
|
j(                  }|D cg c]  }|j*                  d   |k(  s| }}|r|}	 t        | j                  |      }|d   j                   }|j"                  dk(  rt-        |      dk(  ry ||||fS # t        t        f$ r Y y w xY w# t        $ r Y y w xY w# t        $ r Y y w xY wc c}	w c c}w # t        $ r Y w xY w)Nz<lambda>)funcdefclassdefr   r   instance)r   r   getsourcefileOSErrorr   r   existsr   r   r   r   grammarrJ   r   get_used_namesgetparentr<   ra   __code__co_firstlinenorb   r   )r%   r?   original_objectrw   file_iomodule_node
code_linesname_strnamesncodeline_nrra   
line_names	tree_nodes                  r!   _find_syntax_node_namer      s   #O,];$$]3 <4T$ZD	<t{{}  - TlG5K& +?+B+BDI
K*<< ))
 : &&(,,Xr:E
 88==338J 	
E  %%
 %% (-Mtq0AW0LdM
M E&'>'>EJ b	  I~~"|O'D
'R 	7J66U Y   
 &  " N  sX    F F$ F3 :GG #G;GF! F!$	F0/F03	F?>F?	GGc           	         j                   j                  j                  }t        | |      }|Bt	        |      t
        t        t        fv rt        h      S t              }|st        h      S |\  }}}}	||j                  |k7  rj                         j                         }
|
j                         }t        |j                  d            }t        | ||||	|
j!                               }|&| j"                  j%                  |t        |g             |j'                         }t        |j)                  |      h      }|j                  dk(  r j+                         s|j-                         }t        fd|D              S )N.)r   string_namesr   
is_packager   c              3   8   K   | ]  }t        |         yw))r   N)r   ).0r   r   s     r!   	<genexpr>z_create.<locals>.<genexpr>2  s#       	Nz::s   )r   r:   r;   r   r<   dictr_   tupler
   r   r   rk   	get_value
py__name__splitr   r   module_cacheadd
as_contextcreate_valuerg   execute_with_values)r%   r   rp   r?   resultrn   r   r   r   r   root_compiled_valuera   r   module_values    `            r!   rl   rl     sr    #0077<<M#O]CF~4u"55^,--n-^,--6<3Y!^%=%=%L"0"A"A"C"M"M"O&113D C1L&)%.99;L ,,00x?WX)446N ; ;I FGH>>Z'!**,)==? %  r"   ).rO   r   pathlibr   jedi.parser_utilsr   jedir   
jedi.cacher   jedi.inferencer   jedi.file_ior   jedi.inference.namesr	   jedi.inference.base_valuer
   r   r   jedi.inference.valuer   jedi.inference.cacher   r   jedi.inference.compiled.accessr   r   !jedi.inference.gradual.conversionr   jedi.inference.contextr   r   r   objectr3   r   rE   rD   rY   CompiledValueFilterr$   r   r   r   rl   rV   r"   r!   <module>r      s      3  % #  , G G ,! N 5  H	G
, G
T*?$4 *	. 	N N:	
44 	
  ! ".O7d  !) ")r"   