TL iDdZddlmZddlmZddlmZdZ dZ dZ dZ Gd d Z ed Z efd Z Gd dZy)a Recursions are the recipe of |jedi| to conquer Python code. However, someone must stop recursions going mad. Some settings are here to make |jedi| stop at the right time. You can read more about them :ref:`here `. Next to the internal ``jedi.inference.cache`` this module also makes |jedi| not thread-safe, because ``execution_recursion_decorator`` uses class variables to count the function calls. .. _settings-recursion: Settings ~~~~~~~~~~ Recursion settings are important if you don't want extremely recursive python code to go absolutely crazy. The default values are based on experiments while completing the |jedi| library itself (inception!). But I don't think there's any other Python library that uses recursion in a similarly extreme way. Completion should also be fast and therefore the quality might not always be maximal. .. autodata:: recursion_limit .. autodata:: total_function_execution_limit .. autodata:: per_function_execution_limit .. autodata:: per_function_recursion_limit )contextmanager)debug) NO_VALUESceZdZdZy)RecursionDetectorcg|_yN) pushed_nodesselfs ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/inference/recursion.py__init__zRecursionDetector.__init__6s N)__name__ __module__ __qualname__rrrr r 5srr c #K|jj}||vr'tjd|t |dddy |j |d|j y#|j wxYww)z A decorator to detect recursions in statements. In a recursion a statement at the same place, in the same module may not be executed two times. zcatched stmt recursion: %s @%s start_posNFT)recursion_detectorrrwarninggetattrappendpop)inference_statenoders rexecution_allowedr!:ss #55BBL | 6dK6 8      %J    L   sABA+B+A==Bcfd}|S)Ncfd}|S)Nc|jj}|j|} |r}n |fi|}|j|S#|jwxYwr )rexecution_recursion_detectorpush_execution pop_execution)rkwargsdetector limit_reachedresultdefaultfuncs rwrapperzAexecution_recursion_decorator..decorator..wrapperPsa++HHH$33D9M ) $F!$1&1F&&(M&&(s A Ar)r-r.r,s` r decoratorz0execution_recursion_decorator..decoratorOs rr)r,r/s` rexecution_recursion_decoratorr0Ns  rc"eZdZdZdZdZdZy)ExecutionRecursionDetectorz+ Catches recursions of executions. cJ||_d|_g|_i|_d|_y)Nr)_inference_state_recursion_level_parent_execution_funcs_funcdef_execution_counts_execution_count)rrs rrz#ExecutionRecursionDetector.__init__cs* / !')$)+& !rcb|jj|xjdzc_y)N)r6rr5rs rr'z(ExecutionRecursionDetector.pop_executionks% $$((* "rc|j}|xjdz c_|jj||j }|j ry|jt kDrtjdt y|jtk\rtjdty|xjdz c_ |jj|dtk\r0|jdk(rytjdt|y|j|xxdz cc<|jj|t kDrtjd t |yy) Nr:FzRecursion limit (%s) reachedTz%Function execution limit (%s) reachedrtypingz-Per function execution limit (%s) reached: %sz-Per function recursion limit (%s) reached: %s) tree_noder5r6rget_root_contextis_builtins_modulerecursion_limitrrr8total_function_execution_limitr7 setdefaultper_function_execution_limit py__name__countper_function_recursion_limit)r executionfuncdefmodule_contexts rr&z)ExecutionRecursionDetector.push_executionos=%% " $$++G4"335  , , .  ? 2 MM8/ J  $B B MMACa b "  ) ) 4 4Wa @D` `((*h6 MM?,   &&w/14/  ' ' - -g 69U U MM?,  rN)rrr__doc__rr'r&rrrr2r2_s"#*rr2N)rJ contextlibrjedirjedi.inference.base_valuerr@rArCrFr r!r0r2rrrrNsz8&/"% ! !  &+4"::r