
    ^hn,                        S r SSKrSSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  SS	KJr  SS
KJrJrJr  SSKJr  SSKJrJr  SSKJrJr  SSKJr  SSKJrJ r J!r!  \"" 5       r# " S S\5      r$ " S S\\!5      r% " S S\ \%5      r& " S S\5      r' " S S\RP                  5      r)\" 5       S 5       r*S r+S r,\" 5       S 5       r-g)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                      ^  \ rS rSrSrU 4S jrS rS r\" \	S9S 5       r
\4S jr\S	 5       rS
 rS rS rS rS rSrU =r$ )MixedObject   a  
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                 R   > [         TU ]  U5        Xl        UR                  U l        g N)super__init__compiled_valueaccess_handle)selfr   
tree_value	__class__s      W/home/james-whalen/.local/lib/python3.13/site-packages/jedi/inference/compiled/mixed.pyr   MixedObject.__init__,   s$    $,+99    c              /   f   #    [        U R                  U R                  U R                  5      v   g 7fr   )MixedObjectFilterinference_stater   _wrapped_value)r   argskwargss      r"   get_filtersMixedObject.get_filters1   s-       $"5"5t7J7JL 	Ls   /1c                 6    U R                   R                  5       $ r   )r   get_signaturesr   s    r"   r.   MixedObject.get_signatures5   s     ""1133r$   )defaultc                 t    [        U R                  5      nU(       d  U R                  nUR                  U5      $ r   )r   r(   
py__call__)r   	argumentsvaluess      r"   r3   MixedObject.py__call__:   s3     ,,-((F  ++r$   c                 ~    U[         L a  U R                  R                  5       $ U R                  R                  U5      $ r   )	_sentinelr   get_safe_value)r   r1   s     r"   r9   MixedObject.get_safe_valueB   s6    i&&5577&&55g>>r$   c                 .    U R                   R                  $ r   )r   
array_typer/   s    r"   r<   MixedObject.array_typeH   s    ""---r$   c                 6    U R                   R                  5       $ r   )r   get_key_valuesr/   s    r"   r?   MixedObject.get_key_valuesL   s    ""1133r$   c                     U R                   R                  R                  R                  n[	        U5      [
        ;   a  U R                   R                  U5      $ U R                  R                  U5      $ r   )r   r   access_objtyper   py__simple_getitem__r(   )r   indexpython_objects      r"   rE    MixedObject.py__simple_getitem__O   s[    ++99@@EE"77&&;;EBB""77>>r$   c                 6    U R                   R                  5       $ r   )r   negater/   s    r"   rJ   MixedObject.negateU   s    ""))++r$   c                 H    U R                   c  [        U 5      $ [        U 5      $ r   )parent_contextMixedModuleContextMixedContextr/   s    r"   _as_contextMixedObject._as_contextX   s$    &%d++D!!r$   c                     S[        U 5      R                  < SU R                  R                  5       < SU R                  < S3$ )N<z: z; >)rD   __name__r   get_reprr(   r/   s    r"   __repr__MixedObject.__repr__]   s4    J'')
 	
r$   )r   r   )rU   
__module____qualname____firstlineno____doc__r   r+   r.   r   r   r3   r8   r9   propertyr<   r?   rE   rJ   rP   rW   __static_attributes____classcell__r!   s   @r"   r   r      sm     :
L4
 ")4, 5, &/ ? . .4?,"

 
r$   r   c                   $    \ rS rSr\S 5       rSrg)rO   e   c                 .    U R                   R                  $ r   )_valuer   r/   s    r"   r   MixedContext.compiled_valuef   s    {{)))r$    N)rU   rY   rZ   r[   r]   r   r^   rf   r$   r"   rO   rO   e   s    * *r$   rO   c                       \ rS rSrSrg)rN   k   rf   N)rU   rY   rZ   r[   r^   rf   r$   r"   rN   rN   k   s    r$   rN   c                   L   ^  \ rS rSrSrU 4S jr\S 5       r\S 5       r	Sr
U =r$ )	MixedNameo   z:
The ``CompiledName._compiled_value`` is our MixedObject.
c                 0   > [         TU ]  U5        X l        g r   )r   r   _parent_tree_value)r   wrapped_nameparent_tree_valuer!   s      r"   r   MixedName.__init__s   s    &"3r$   c                 v    [        U R                  5       5      nU(       d  gUS   R                  R                  $ )N)r   r   r   )listinfername	start_pos)r   r5   s     r"   ru   MixedName.start_posw   s,    djjl#ay~~'''r$   c           	         U R                   R                  5       nU R                  nUR                  5       (       d  UR	                  5       (       aU  UR                  U R                  5      nUR                  5       (       a%  [        U Vs1 s H  n[        X5      iM     sn5      $ UR                  5       n[        U R                  X5      $ s  snf r   )_wrapped_nameinfer_compiled_valuerm   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"   rs   MixedName.infer   s    ++@@B,,
!!##z':':'<'<$778H8HIK))++ UA^!? UVV#446t,,nMM !Vs   
C)rm   )rU   rY   rZ   r[   r\   r   r]   ru   r   rs   r^   r_   r`   s   @r"   rj   rj   o   s7    4 ( ( 	N 	Nr$   rj   c                   4   ^  \ rS rSrU 4S jrU 4S jrSrU =r$ )r&      c                 0   > [         TU ]  X5        X0l        g r   )r   r   _tree_value)r   r'   r   r    r!   s       r"   r   MixedObjectFilter.__init__   s    9%r$   c                 L   > [        [        TU ]  " U0 UD6U R                  5      $ r   )rj   r   _create_namer   )r   r)   r*   r!   s      r"   r   MixedObjectFilter._create_name   s+    G $1&1
 	
r$   )r   )rU   rY   rZ   r[   r   r   r^   r_   r`   s   @r"   r&   r&      s    &
 
r$   r&   c                 z    U R                  US[        R                  [        R                  S9R	                  5       $ )NT)pathcache
diff_cache
cache_path)parser   fast_parsercache_directoryget_root_node)r'   r   s     r"   _load_moduler      s;      ''++	 ! 
 mor$   c                     [         R                  " U 5      n [         R                  " U 5      (       d  [         R                  " U 5      (       d  [         R
                  " U 5      (       dl  [         R                  " U 5      (       dQ  [         R                  " U 5      (       d6  [         R                  " U 5      (       d  [         R                  " U 5      (       a  U $  U R                  $ ! [         a     Nf = f! [         a    [        ef = f)z9Check if inspect.getfile has a chance to find the source.)inspectunwrap
ValueErrorismoduleisclassismethod
isfunctionistracebackisframeiscoder!   AttributeError	TypeError)rG   s    r"   _get_object_to_checkr      s    }5
 	''}--..!!-00""=11}--~~m,,&&&    s   C$ C4 $
C10C14Dc                    Un [        U5      n[        R                  " U5      nUc  S O
[        U5      n Ub  UR                  5       (       d  g  [        U5      n[        X5      n[        R                  " U5      (       a  [        U R                  U5      nXUXF4$  UR                  nUS:X  a  g UR                  5       R                  U/ 5      nU V	s/ s H=  n	U	R                   R"                  S;   d  M  U	R                   R$                  U	:X  d  M;  U	PM?     nn	U(       d  g  UR&                  n
U
R(                  nU Vs/ s H  oR*                  S   U:X  d  M  UPM     nnU(       a  Un[        U R                  U5      nUS   R                   nUR"                  S:X  a  [-        U5      S:X  a  g X^XF4$ ! [        [        4 a     g f = f! [         a     g f = f! [         a     g f = fs  sn	f s  snf ! [         a     Nf = f)Nz<lambda>)funcdefclassdefr   r   instance)r   r   getsourcefileOSErrorr   r   existsr   r   r   r   grammarrU   r   get_used_namesgetparentrD   rt   __code__co_firstlinenoru   r   )r'   rG   original_objectr   file_iomodule_node
code_linesname_strnamesncodeline_nrrt   
line_names	tree_nodes                  r"   _find_syntax_node_namer      s   #O,];$$]3 <4T$ZD	<t{{}}  - TlG5K&& +?+B+BDI
<< ))
 : &&(,,Xr:E
 a88==33 	
898J 	
5 
  %%
 %% (-Mutq0AW0Ldu
M E&'>'>EJ b	  I~~"|O'D
'R 766U Y   
 &  " N  sd   !F2 G G G(5G(G("G2 >G-G-2GG
GG
G%$G%2
G?>G?c           	      &  ^ TR                   R                  R                  n[        X5      nUcJ  [	        U5      [
        [        [        4;   a  [        T15      $ [        T5      nU(       d  [        T15      $ GOUu  pgpUb  UR                  U:w  a  TR                  5       R                  5       n
U
R                  5       n[        UR                  S5      5      n[        XUUU	U
R!                  5       S9nUb&  U R"                  R%                  U[        U/5      5        UR'                  5       n[        UR)                  U5      15      nUR                  S:X  a%  TR+                  5       (       d  UR-                  5       n[        U4S jU 5       5      $ )N.)r   string_namesr   
is_packager   c              3   8   >#    U  H  n[        TUS 9v   M     g7f))r    N)r   ).0r    r   s     r"   	<genexpr>_create.<locals>.<genexpr>2  s      %J 	Nz:%s   )r   rB   rC   r   rD   dictrr   tupler
   r   r   r   	get_value
py__name__splitr   r   module_cacheadd
as_contextcreate_valuer{   execute_with_values)r'   r   r   rG   resultr   r   r   r   r   root_compiled_valuert   r   module_values    `            r"   r   r     st    #0077<<M#OCF~4u"55^,--n-^,--  7=3!^%=%=%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$   ).r\   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   objectr8   r   rO   rN   rj   CompiledValueFilterr&   r   r   r   r   rf   r$   r"   <module>r      s      3  % #  , G G ,! N 5  H	G
, G
T*?$4 *	. 	N N:	
44 	
  ! ".O7d  !) ")r$   