uBFjDdZddlmZddlmZddlmZdZ dZ dZ dZ Gd d Z ed Z efd Z Gd dZdS)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_VALUESceZdZdZdS)RecursionDetectorcg|_dSN) pushed_nodesselfs FC:\PYTHON\_runtimes\venv\Lib\site-packages\jedi/inference/recursion.py__init__zRecursionDetector.__init__6sN)__name__ __module__ __qualname__rrrr r 5s#rr c #K|jj}||vr+tjd|t |dddVdS ||dV|dS#|wxYw)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!:s #5BL | 6dK66 8 8 8      % % %JJJ        L      s A..Bcfd}|S)Ncfd}|S)Nc|jj}||} |r}n |fi|}|n#|wxYw|Sr )rexecution_recursion_detectorpush_execution pop_execution)rkwargsdetector limit_reachedresultdefaultfuncs rwrapperzAexecution_recursion_decorator..decorator..wrapperPs~+HH$33D99M ) 2$FF!T$11&11F&&((((&&((((Ms AAr)r-r.r,s` r decoratorz0execution_recursion_decorator..decoratorOs)      rr)r,r/s` rexecution_recursion_decoratorr0Ns$      rc$eZdZdZdZdZdZdS)ExecutionRecursionDetectorz+ Catches recursions of executions. cL||_d|_g|_i|_d|_dS)Nr)_inference_state_recursion_level_parent_execution_funcs_funcdef_execution_counts_execution_count)rrs rrz#ExecutionRecursionDetector.__init__cs0 / !')$)+& !rcX|j|xjdzc_dS)N)r6rr5rs rr'z(ExecutionRecursionDetector.pop_executionks1 $((*** "rc|j}|xjdz c_|j||}|rdS|jt krtjdt dS|j tkrtjdtdS|xj dz c_ |j |dtkr7|dkrdStjdt|dS|j |xxdz cc<|j|t krtjd t |dSdS) 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% " $++G444"3355  , , . . 5  ? 2 2 M8/ J J J4  $B B B MACa b b b4 "  ) 4 4Wa @ @D` ` `((**h66u M?,    4 &w///14///  ' - -g 6 69U U U M?,    4urN)rrr__doc__rr'r&rrrr2r2_sK"""###*****rr2N)rJ contextlibrjedirjedi.inference.base_valuerr@rArCrFr r!r0r2rrrrNs8&%%%%%//////"% ! !  &+4"::::::::::r