ó
    Ð]jî"  ã                   óà   • S r SSKJr  SSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr  SS	KJr  SS
K	Jr  SSKJr  SSKJrJrJr  SSKJrJr  SSKJrJrJr  SSKJr  SSKJr   " S S5      r g)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.
é    )ÚAnyN)Ú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                   ó2  • \ rS rSr% S\S'   SS jrSS jr\\R                  " 5       S 5       5       r
\\" 5       S 5       5       r\\" 5       S	 5       5       r\\" 5       S
 5       5       r\" 5       S 5       r\" 5       S 5       rS rS rS r  SS jrS rSrg)ÚInferenceStateéV   z	list[Any]Úanalysis_modulesNc                 óî  • Uc  UR                  5       nX l        X0l        UR                  U 5      U l        UR                  5       U l        [        R                  " SS9U l	        0 U l
        [        R                  " 5       U l        0 U l        0 U l        0 U l        0 U l        / U l        SU l        [(        R*                  U l        SU l        Xl        0 U l        SU l        SU l        U R9                  5         g )Nz3.13)Úversionr   FT)Ú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_depthr   Údynamic_paramsÚdo_dynamic_params_searchÚis_analysisÚprojectÚaccess_cacheÚallow_unsafe_executionsÚflow_analysis_enabledÚreset_recursion_limitations)Úselfr2   r   r   s       ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/jedi/inference/__init__.pyÚ__init__ÚInferenceState.__init__Y   sß   € ØÑØ!×1Ñ1Ó3ˆKØ&ÔØ&ÔØ#.×#MÑ#MÈdÓ#SˆÔ Ø"×.Ñ.Ó0ˆŒä#×0Ò0¸Ñ@ˆÔØˆÔÜ#×/Ò/Ó1ˆÔØ!#ˆÔØ ˆÔØ')ˆÔ$ØˆÔØˆŒØ$%ˆÔ!Ü(0×(?Ñ(?ˆÔ%Ø ˆÔØŒØˆÔØ',ˆÔ$Ø%)ˆÔ"à×(Ñ(Õ*ó    c                 ó,   • [         R                  " XX#S9$ )N)Úprefer_stubs)r   Úimport_module_by_names)r7   Úimport_namesÚsys_pathr=   s       r8   Úimport_moduleÚInferenceState.import_modules   s   € Ü×-Ò-Ø ñEð 	Er;   c                 óà   • [         R                  " SX5        [         R                  " 5          U R                  US9nS S S 5        [         R                  " SWU 5        U$ ! , (       d  f       N(= f)Nzexecute: %s %s)Ú	argumentszexecute result: %s in %s)r   ÚdbgÚincrease_indent_cmÚ
py__call__)ÚvaluerD   Ú	value_sets      r8   ÚexecuteÚInferenceState.executew   sW   € ô 	�	Š	Ð" EÔ5Ü×%Ò%Õ'Ø×(Ñ(°9Ð(Ð=ˆI÷ (ä�	Š	Ð,¨i¸Ô?ØÐ÷ (Õ'ús   ­AÁ
A-c                 ó0   • SnU R                  U4/ S9u  nU$ )NÚbuiltins)r@   ©rA   )r7   Úmodule_nameÚbuiltins_modules      r8   rP   ÚInferenceState.builtins_module�   s)   € ð !ˆØ×-Ñ-¨{¨nÀrÐ-ÐJÑˆØÐr;   c                 ó,   • U R                  S5      u  nU$ )N)ÚtypingrN   ©r7   Útyping_modules     r8   rU   ÚInferenceState.typing_moduleˆ   s   € ð ×+Ñ+¨KÓ8‰ˆØÐr;   c                 ó,   • U R                  S5      u  nU$ )N)ÚtypesrN   rT   s     r8   Útypes_moduleÚInferenceState.types_moduleŽ   s   € ð ×+Ñ+¨JÓ7‰ˆØÐr;   c                 ó8   • U R                   R                  S5      $ )NÚTuple©rU   Úpy__getattribute__©r7   s    r8   Útyping_tupleÚInferenceState.typing_tuple”   s   € à×!Ñ!×4Ñ4°WÓ=Ð=r;   c                 ó8   • U R                   R                  S5      $ )NÚTyper]   r_   s    r8   Útyping_typeÚInferenceState.typing_type˜   s   € à×!Ñ!×4Ñ4°VÓ<Ð<r;   c                 ón   • [         R                  " 5       U l        [         R                  " U 5      U l        g )N)r   ÚRecursionDetectorÚrecursion_detectorÚExecutionRecursionDetectorÚexecution_recursion_detectorr_   s    r8   r6   Ú*InferenceState.reset_recursion_limitationsœ   s'   € Ü"+×"=Ò"=Ó"?ˆÔÜ,5×,PÒ,PÐQUÓ,VˆÕ)r;   c                 ó<   • U R                   R                  " U 40 UD6$ )zConvenience function)r2   Ú_get_sys_path)r7   Úkwargss     r8   Úget_sys_pathÚInferenceState.get_sys_path    s   € à�|‰|×)Ò)¨$Ñ9°&Ñ9Ð9r;   c                 óB  • UR                  SS9nUGbg  UR                  nUS:H  nU(       d  US:X  aJ  U(       a  [        XUR                  5      nO [        R
                  " XR                  5      n[        U/5      $ US:X  a,  UR                  R                  S;  nU(       a  [        XU5      $ US:X  aW  UR                  UR                  S   5      n[        XR                  S   5      n	[        X‰5      n
[        X5      n[        Xº5      $ US	;   a  [        R                  " X5      $ US
:X  a  [!        XU5      $ US:X  a$  UR#                  UR$                  UR&                  S9$ US:X  a  UR                  U5      $ O[)        X5      nUb  U$ [*        R,                  " X5      $ )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Úchildrenr   r   r   r   r   Úinfer_importr   r^   rH   Úend_posr   r
   Úinfer_call_of_leaf)r7   ÚcontextÚnameÚdef_Útype_Úis_classdefÚcÚis_simple_nameÚcontainer_typesÚcnÚ	for_typesÚnÚresults                r8   ÚinferÚInferenceState.infer¤   s‡  € Ø×"Ñ"°dÐ"Ð;ˆØÒØ—I‘IˆEØ :Ñ-ˆKÞ˜e yÓ0ÞÜ" 4°$·+±+Ó>‘Aä%×2Ò2°7¿K¹KÓH�AÜ  “}Ð$à˜Ó#Ø!%§¡×!1Ñ!1Ð9MÑ!M�Þ!Ü*¨7¸$Ó?Ð?Ø˜
Ó"Ø")×"4Ñ"4°T·]±]À1Ñ5EÓ"F�Ü'¨·±¸qÑ1AÓB�Ü*¨?Ó?�	Ü& wÓ5�Ü.¨qÓ<Ð<ØÐ6Ó6Ü×+Ò+¨GÓ:Ð:Ø˜Ó#Ü*¨4¸$Ó?Ð?Ø˜'Ó!Ø×1Ñ1°$·*±*ÀtÇ|Á|Ð1ÐTÐTØÐ*Ó*Ø×)Ñ)¨$Ó/Ð/ð +ô ;¸7ÓIˆFØÑ!Ø�ä×)Ò)¨'Ó8Ð8r;   c                 ó<  • Uc  Uc  [        U5      nUR                  5       n[        R                  " USSS9n[	        U5      [
        R                  :”  a  US [
        R                   nU(       a  U R                  OU R                  nUR                  " SXUS.UD6U4$ )Nzutf-8Úreplace)ÚencodingÚerrors)ÚcodeÚpathÚfile_io© )
r   Úreadr#   Úpython_bytes_to_unicodeÚlenr   Ú_cropped_file_sizer%   r"   Úparse)r7   r›   rœ   Úuse_latest_grammarr�   rn   r"   s          r8   Úparse_and_get_codeÚ!InferenceState.parse_and_get_codeÉ   sŠ   € à‰<Ø‰Ü  ›,�Ø—<‘<“>ˆDä×,Ò,¨T¸GÈIÑVˆäˆt‹9”x×2Ñ2Ó2ØÐ4œ×4Ñ4Ð5ˆDæ);�$×%Ò%ÀÇÁˆØ�}Š}ÐM $¸7ÑMÀfÑMÈtÐSÐSr;   c                 ó,   • U R                   " U0 UD6S   $ )Nr   )r¥   )r7   Úargsrn   s      r8   r£   ÚInferenceState.parseØ   s   € Ø×&Ò&¨Ð7°Ñ7¸Ñ:Ð:r;   )r3   r4   r-   r*   r    r0   r.   r   rj   r5   r"   r+   r1   r%   r&   r,   r(   r2   rh   r   r)   )NN)NT)NNFN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotations__r9   rA   Ústaticmethodr   ÚdecoraterJ   Úpropertyr	   rP   rU   rY   r`   rd   r6   ro   r•   r¥   r£   Ú__static_attributes__rž   r;   r8   r   r   V   sç   ‡ Ø!Ó!ô+ô4Eð Ø×ÒÓñó ó ðð Ù#Ó%ñó &ó ðð
 Ù#Ó%ñó &ó ðð Ù#Ó%ñó &ó ðñ $Ó%ñ>ó &ð>ñ $Ó%ñ=ó &ð=òWò:ò#9ðJ 26Ø=AôTõ;r;   r   )!Ú__doc__rS   r   r#   Újedi.file_ior   Újedir   r   Újedi.inferencer   r   Újedi.inference.cacher	   r
   Újedi.inference.namesr   Újedi.inference.base_valuer   r   r   Újedi.inference.valuer   r   Újedi.inference.syntax_treer   r   r   Újedi.inference.importsr   Újedi.pluginsr   r   rž   r;   r8   Ú<module>r¾      sT   ðñ?õ@ ã Ý å Ý Ý "Ý $Ý ?Ý "Ý 3÷ñ ç :÷1ñ 1å HÝ '÷C;ò C;r;   