Format: application/x-python-code
⬇ Download File (8.9 KB)
   1  o
   2  
   3  �hn,�@sLdZddlZddlmZddlmZddlmZddlm	Z	ddl
   4  mZddlm
   5  Z
   6  dd	lmZdd
   7  lmZmZmZddlmZddlmZmZdd
   8  lmZmZddlmZddlmZm Z m!Z!e"�Z#Gdd�de�Z$Gdd�dee!�Z%Gdd�de e%�Z&Gdd�de�Z'Gdd�dej(�Z)e�dd��Z*dd�Z+dd�Z,e�d d!��Z-dS)"z 
   9  Used only for REPL Completion.
  10  �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�TreeContextMixincs�eZdZdZ�fdd�Zdd�Zdd�Zeed�d	d
  11  ��Z	e
  12  fdd�Zed
  13  d��Z
  14  dd�Zdd�Zdd�Zdd�Zdd�Z�ZS)�MixedObjecta�
  15      A ``MixedObject`` is used in two ways:
  16  
  17      1. It uses the default logic of ``parser.python.tree`` objects,
  18      2. except for getattr calls and signatures. The names dicts are generated
  19         in a fashion like ``CompiledValue``.
  20  
  21      This combined logic makes it possible to provide more powerful REPL
  22      completion. It allows side effects that are not noticable with the default
  23      parser structure to still be completable.
  24  
  25      The biggest difference from CompiledValue to MixedObject is that we are
  26      generally dealing with Python code and not with C code. This will generate
  27      fewer special cases, because we in Python you don't have the same freedoms
  28      to modify the runtime.
  29      cst��|�||_|j|_dS�N)�super�__init__�compiled_value�
  30  access_handle)�selfr�
  31  tree_value��	__class__��Sc:\Users\shubh\Videos\agent\nova\Lib\site-packages\jedi/inference/compiled/mixed.pyr,szMixedObject.__init__cos�t|j|j|j�VdSr)�MixedObjectFilter�inference_stater�_wrapped_value�r�args�kwargsrrr �get_filters1s�
  32  �zMixedObject.get_filterscC�
  33  |j��Sr)r�get_signatures�rrrr r)5s
  34  zMixedObject.get_signatures)�defaultcCst|j�}|s
  35  |j}|�|�Sr)rr#�
  36  py__call__)r�	arguments�valuesrrr r,:s
  37  
  38  zMixedObject.py__call__cCs|tur	|j��S|j�|�Sr)�	_sentinelr�get_safe_value)rr+rrr r0Bs
  39  zMixedObject.get_safe_valuecC�|jjSr)r�
  40  array_typer*rrr r2H�zMixedObject.array_typecCr(r)r�get_key_valuesr*rrr r4L�
  41  zMixedObject.get_key_valuescCs0|jjjj}t|�tvr|j�|�S|j�|�Sr)rr�access�_obj�typer�py__simple_getitem__r#)r�index�
  42  python_objectrrr r9Osz MixedObject.py__simple_getitem__cCr(r)r�negater*rrr r<Ur5zMixedObject.negatecCs|jdur	t|�St|�Sr)Zparent_context�MixedModuleContext�MixedContextr*rrr �_as_contextXs
  43  zMixedObject._as_contextcCsdt|�j|j��|jfS)Nz<%s: %s; %s>)r8�__name__rZget_reprr#r*rrr �__repr__]s
  44  �zMixedObject.__repr__)r@�
  45  __module__�__qualname__�__doc__rr'r)rrr,r/r0�propertyr2r4r9r<r?rA�
  46  __classcell__rrrr rs
  47  
  48  rc@seZdZedd��ZdS)r>cCr1r)�_valuerr*rrr rfr3zMixedContext.compiled_valueN)r@rBrCrErrrrr r>esr>c@seZdZdS)r=N)r@rBrCrrrr r=ksr=cs8eZdZdZ�fdd�Zedd��Zedd��Z�Z	S)�	MixedNamezB
  49      The ``CompiledName._compiled_value`` is our MixedObject.
  50      cst��|�||_dSr)rr�_parent_tree_value)rZwrapped_nameZparent_tree_valuerrr rss
  51  zMixedName.__init__cCs t|���}|s
  52  dS|djjS)N)rrr)�list�infer�name�	start_pos)rr.rrr rMwszMixedName.start_poscs`|j���|j}|��s|��r%|�|j�}���r%t�fdd�|D��S|�	�}t
  53  |j�|�S)Ncsh|]}t�|��qSr�r)�.0�v�rrr �	<setcomp>�sz"MixedName.infer.<locals>.<setcomp>)Z
  54  _wrapped_nameZinfer_compiled_valuerIZis_instance�is_classZpy__getattribute__Zstring_nameZis_functionr	�get_root_context�_createZ_inference_state)rr�tree_values�module_contextrrQr rKs
  55  zMixedName.infer)
  56  r@rBrCrDrrErMrrKrFrrrr rHos
  57  rHcs(eZdZ�fdd�Z�fdd�Z�ZS)r!cst��||�||_dSr)rr�_tree_value)rr"rrrrr r�s
  58  zMixedObjectFilter.__init__cstt�j|i|��|j�Sr)rHr�_create_namerXr$rrr rY�s�zMixedObjectFilter._create_name)r@rBrCrrYrFrrrr r!�sr!cCs|j|dtjtjd���S)NT)�path�cacheZ
  59  diff_cache�
  60  cache_path)�parserZfast_parserZcache_directoryZ
  61  get_root_node)r"rZrrr �_load_module�s��r^cCs�zt�|�}Wn	tyYnwt�|�s4t�|�s4t�|�s4t�|�s4t�|�s4t�|�s4t�	|�r6|Sz|j
  62  WStyCt�w)z9Check if inspect.getfile has a chance to find the source.)
  63  �inspect�unwrap�
  64  ValueError�ismodule�isclass�ismethod�
  65  isfunction�istraceback�isframe�iscoder�AttributeError�	TypeError)r;rrr �_get_object_to_check�s0�
  66  �������rkc	sx|}zt|�}t�|�}WnttfyYdSw|dur dnt|�}z
  67  |dus-|��s0WdSWn
  68  ty;YdSwt|�}t||�}t�	|�rVt
  69  |j|�}||||fSz|j}Wn
  70  t
  71  yeYdSw|dkrldS|���|g�}dd�|D�}|sdSz|j}	|	j�Wn	t
  72  y�Ynw�fdd�|D�}
  73  |
  74  r�|
  75  }t
  76  |j|�}|dj}|jdkr�t|�dkr�dS||||fS)Nz<lambda>cSs(g|]}|jjdvr|jj|kr|�qS))�funcdef�classdef)�parentr8rL)rO�nrrr �
  77  <listcomp>�s
  78  �z*_find_syntax_node_name.<locals>.<listcomp>csg|]}|jd�kr|�qS)r)rM)rOrL�Zline_nrrr rp�s�����rl�instance)rkr_�
  79  getsourcefile�OSErrorrjr�existsrr^rbrZgrammarr@riZget_used_names�get�__code__�co_firstlinenornr8r)r"r;Zoriginal_objectrZ�file_io�module_node�
  80  code_linesZname_str�names�codeZ
  81  line_names�	tree_noderrqr �_find_syntax_node_name�s^���
  82  
  83  
  84  ��
  85  �
  86  r�cs�jjj}t||�}|dur(t|�tttfvrt�h�St	��}|s't�h�SnS|\}}}}	|dus7|j
  87  |krf�����}
  88  |
  89  �
  90  �}t|�d��}t|||||	|
  91  ��d�}
  92  |durb|j�|t|
  93  g��|
  94  ��}t|�|�h�}|jdkr{���s{|��}t�fdd�|D��S)N�.)rz�string_namesr|�
  95  is_packagermc3s�|]	}t�|d�VqdS))rNrN)rOrrQrr �	<genexpr>2s
  96  �
  97  �
  98  �z_create.<locals>.<genexpr>)rr6r7r�r8�dictrJ�tupler	rrrT�	get_valueZ
  99  py__name__�splitrr�Zmodule_cache�addZ
 100  as_contextZcreate_valuerSZexecute_with_values)r"rrWr;�resultrVr{rrzr|Zroot_compiled_valuerLr�Zmodule_valuerrQr rUs>
 101  
 102  
 103  
 104  ��
 105  �rU).rDr_�pathlibrZjedi.parser_utilsrZjedirZ
 106  jedi.cacherZjedi.inferencerZjedi.file_iorZjedi.inference.namesrZjedi.inference.base_valuer	r
 107  rZjedi.inference.valuerZjedi.inference.cacher
 108  rZjedi.inference.compiled.accessrrZ!jedi.inference.gradual.conversionrZjedi.inference.contextrrr�objectr/rr>r=rHZCompiledValueFilterr!r^rkr�rUrrrr �<module>s6J
 109  	R