Format: application/x-python-code
1 o
2
3 �hD � @ sx d Z ddlmZ ddlmZ ddlmZ dZ dZ dZ dZ
4 G d d
5 � d
6 �Zedd� �Zefd
7 d�Z
8 G dd� d�ZdS )a
9 Recursions are the recipe of |jedi| to conquer Python code. However, someone
10 must stop recursions going mad. Some settings are here to make |jedi| stop at
11 the right time. You can read more about them :ref:`here <settings-recursion>`.
12
13 Next to the internal ``jedi.inference.cache`` this module also makes |jedi| not
14 thread-safe, because ``execution_recursion_decorator`` uses class variables to
15 count the function calls.
16
17 .. _settings-recursion:
18
19 Settings
20 ~~~~~~~~~~
21
22 Recursion settings are important if you don't want extremely
23 recursive python code to go absolutely crazy.
24
25 The default values are based on experiments while completing the |jedi| library
26 itself (inception!). But I don't think there's any other Python library that
27 uses recursion in a similarly extreme way. Completion should also be fast and
28 therefore the quality might not always be maximal.
29
30 .. autodata:: recursion_limit
31 .. autodata:: total_function_execution_limit
32 .. autodata:: per_function_execution_limit
33 .. autodata:: per_function_recursion_limit
34 � )�contextmanager)�debug)� NO_VALUES� �� � � c @ s e Zd Zdd� ZdS )�RecursionDetectorc C s
35 g | _ d S �N)�pushed_nodes��self� r �Nc:\Users\shubh\Videos\agent\nova\Lib\site-packages\jedi/inference/recursion.py�__init__6 s
36 zRecursionDetector.__init__N)�__name__�
37 __module__�__qualname__r r r r r r 5 s r c c s\ � | j j}||v rt�d|t|dd�� dV dS z|�|� dV W |�� dS |�� w )z�
38 A decorator to detect recursions in statements. In a recursion a statement
39 at the same place, in the same module may not be executed two times.
40 zcatched stmt recursion: %s @%s� start_posNFT)Zrecursion_detectorr r �warning�getattr�append�pop)�inference_state�noder r r r �execution_allowed: s �
41 �
42
43 r c s � fdd�}|S )Nc s �� fdd�}|S )Nc sT | j j}|�| �}z|r� }n�| fi |��}W |�� |S W |�� |S |�� w r
44 )r Zexecution_recursion_detector�push_execution�
45 pop_execution)r
46 �kwargs�detectorZ
47 limit_reached�result)�default�funcr r �wrapperP s
48 �
49 �zAexecution_recursion_decorator.<locals>.decorator.<locals>.wrapperr )r"