Format: application/x-python-code
⬇ Download File (7.2 KB)
   1  o
   2  
   3  �h��@s�ddlZddlmZddlmZddlmZddlmZm	Z	ddl
   4  mZmZm
   5  Z
   6  mZddlmZddlmZdd	lmZdd
   7  lmZddlmZddlmZdd
   8  lmZGdd�de�ZGdd�d�ZGdd�de�ZGdd�dee�ZdS)�N)�Path)�Optional)�inference_state_method_cache)�AbstractNameDefinition�
   9  ModuleName)�GlobalNameFilter�ParserTreeFilter�
  10  DictFilter�MergedFilter)�compiled)�	TreeValue)�
  11  SubModuleName)�values_from_qualified_names)�create_simple_object)�ValueSet��
  12  ModuleContextc@s&eZdZdZdZddd�Zdd�ZdS)	�_ModuleAttributeNamezA
  13      For module attributes like __file__, __str__ and so on.
  14      �instanceNcCs||_||_||_dS�N)�parent_context�string_name�
  15  _string_value)�self�
  16  parent_modulerZstring_value�r�Qc:\Users\shubh\Videos\agent\nova\Lib\site-packages\jedi/inference/value/module.py�__init__s
  17  z_ModuleAttributeName.__init__cCs2|jdur|j}tt|jj|�g�St�|jj�Sr)rrrr�inference_staterZget_string_value_set)r�srrr�infers
  18  �z_ModuleAttributeName.inferr)�__name__�
  19  __module__�__qualname__�__doc__�api_typerr rrrrrs
  20  
  21  rc@seZdZe�dd��ZdS)�SubModuleDictMixincCs>i}|��r|jj�|���}|D]}t|��|�||<q|S)zf
  22          Lists modules in the directory of this module (if this module is a
  23          package).
  24          )�
  25  is_packagerZcompiled_subprocessZiter_module_names�
  26  py__path__r
  27  �
  28  as_context)r�names�mods�namerrr�sub_modules_dict&s�z#SubModuleDictMixin.sub_modules_dictN)r!r"r#rr-rrrrr&%sr&c@sreZdZeZddd�Zdd�Zdd�Zdd	�Ze	e
  29  �d
  30  d���Ze
  31  �dd
  32  ��Zdd�Z
  33  e
  34  g�dd��Zdd�ZdS)�ModuleMixinNccsP�tt|��|d�t|����Vt|���Vt|���V|��EdHdS)N)r�origin_scope)r
  35  rr)rr	r-�_module_attributes_dict�iter_star_filters)rr/rrr�get_filters=s��
  36  �zModuleMixin.get_filterscCst|jdd�\}|S)N�types�
  37  ModuleType)rr)r�crrr�py__class__IszModuleMixin.py__class__cC�dS)NTr�rrrr�	is_moduleM�zModuleMixin.is_modulecCr7)NFrr8rrr�is_stubPr:zModuleMixin.is_stubcCs|�||jd�S�N�����)�_module_name_class�string_namesr8rrrr,SszModuleMixin.namecsFgd�}t�fdd�|D��}���}|dur!t�dt|��|d<|S)N)�__package__r$r!c3s�|]
  38  }|t�|�fVqdSr)r)�.0�nr8rr�	<genexpr>\s�z6ModuleMixin._module_attributes_dict.<locals>.<genexpr>�__file__)�dict�
  39  py__file__r�str)rr*�dct�pathrr8rr0Xsz#ModuleMixin._module_attributes_dictccs4�|��D]}t|��d�}|dusJ�|VqdSr)�star_imports�nextr2)rZstar_module�frrrr1bs��zModuleMixin.iter_star_filterscCs|ddlm}g}|��}|j��D]*}|��r;||j|��d||jd��	�}|D]
  40  }t
  41  |t�r6||��7}q)||7}q|S)Nr)�Importerr=)Zimport_path�module_context�level)
  42  Zjedi.inference.importsrMr)�	tree_nodeZiter_importsZis_star_importr�	get_pathsrO�follow�
  43  isinstance�ModuleValuerJ)rrM�modulesrN�i�new�modulerrrrJks(
  44  ��
  45  ��zModuleMixin.star_importscCr7)z�
  46          A module doesn't have a qualified name, but it's important to note that
  47          it's reachable and not `None`. With this information we can add
  48          qualified names on top for all value children.
  49          rrr8rrr�get_qualified_names�szModuleMixin.get_qualified_namesr)r!r"r#rr>r2r6r9r;�propertyrr,r0r1rJrYrrrrr.:s
  50  
  51  		
  52  r.csteZdZdZ		d�fdd�	Z�fdd�Zdd	�Zd
  53  eefdd�Z	d
  54  d�Z
  55  dd�Zdd�Zdd�Z
  56  dd�Z�ZS)rTrXNFcsFt�j|d|d�||_|durd|_n|j|_||_||_||_dS)N)rrP)�superr�file_io�_pathrIr?�
  57  code_lines�_is_package)rrZmodule_noder^r\r?r'��	__class__rrr�s�
  58  zModuleValue.__init__cs$|jdur
  59  |jjdkr
  60  dSt���S)Nz.pyiT)r]�suffixr[r;r8r`rrr;�s
  61  zModuleValue.is_stubcCs|jdurdSd�|j�S)N�.)r?�joinr8rrr�
  62  py__name__�s
  63  zModuleValue.py__name__�returncCs|jdurdS|j��S)z?
  64          In contrast to Python's __file__ can be None.
  65          N)r]�absoluter8rrrrF�s
  66  
  67  zModuleValue.py__file__cCs|jSr)r_r8rrrr'�szModuleValue.is_packagecCs(|jdurgS|jr
  68  |jS|jdd�Sr<)r?r_r8rrr�
  69  py__package__�s
  70  
  71  zModuleValue.py__package__cCs�|jsdSd�|jdd��}d}|d|vs|d|vrBt�}|j��D]}tj�||jj	�}tj�
  72  |�r;|�|�q%|rBt|�S|�
  73  �}|dusLJ�tj�|�gS)z�
  74          In case of a package, this returns Python's __path__ attribute, which
  75          is a list of paths (strings).
  76          Returns None if the module is not a package.
  77          N��2)zdeclare_namespace(__name__)zextend_path(__path__r�)r_rdr^�setrZget_sys_path�osrIr,r�isdir�add�listrF�dirname)rZfirst_few_lines�options�pathsr�other�filerrrr(�s 
  78  �zModuleValue.py__path__cCst|�Srrr8rrr�_as_context�szModuleValue._as_contextcCs.d|jj|��|jjd|jjd|��fS)Nz<%s: %s@%s-%s is_stub=%s>r)rar!rerP�	start_pos�end_posr;r8rrr�__repr__�s
  79  �zModuleValue.__repr__)NNF)r!r"r#r%rr;rerrrFr'rhr(rvry�
  80  __classcell__rrr`rrT�s�	!rT)rm�pathlibr�typingrZjedi.inference.cacherZjedi.inference.namesrrZjedi.inference.filtersrrr	r
  81  Zjedi.inferencerZjedi.inference.base_valuerr
  82  Zjedi.inference.helpersrZjedi.inference.compiledrrZjedi.inference.contextrrr&r.rTrrrr�<module>s"O