TL in,dZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z dd lmZdd lmZmZmZdd lmZdd lmZmZdd lmZmZddlmZddlmZm Z m!Z!e"Z#GddeZ$Gddee!Z%Gdde e%Z&GddeZ'Gdde jPZ)edZ*dZ+dZ,edZ-y)z Used only for REPL Completion. N)Path)get_cached_code_lines)settings)memoize_method)compiled)FileIO) NameWrapper)ValueSet ValueWrapper NO_VALUES) ModuleValue)inference_state_function_cacheinference_state_method_cache)ALLOWED_GETITEM_TYPES get_api_type)to_stub)CompiledContextCompiledModuleContextTreeContextMixinceZdZdZfdZdZdZeedZ e fdZ e dZ d Zd Zd Zd Zd ZxZS) MixedObjecta A ``MixedObject`` is used in two ways: 1. It uses the default logic of ``parser.python.tree`` objects, 2. except for getattr calls and signatures. The names dicts are generated in a fashion like ``CompiledValue``. This combined logic makes it possible to provide more powerful REPL completion. It allows side effects that are not noticable with the default parser structure to still be completable. The biggest difference from CompiledValue to MixedObject is that we are generally dealing with Python code and not with C code. This will generate fewer special cases, because we in Python you don't have the same freedoms to modify the runtime. cTt||||_|j|_yN)super__init__compiled_value access_handle)selfr tree_value __class__s c/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/inference/compiled/mixed.pyrzMixedObject.__init__,s& $,+99c/fKt|j|j|jywr)MixedObjectFilterinference_stater_wrapped_value)rargskwargss r! get_filterszMixedObject.get_filters1s.  $"5"5t7J7JL Ls/1c6|jjSr)rget_signaturesrs r!r+zMixedObject.get_signatures5s""1133r")defaultcjt|j}|s |j}|j|Sr)rr& py__call__)r argumentsvaluess r!r/zMixedObject.py__call__:s3,,-((F  ++r"c||tur|jjS|jj|Sr) _sentinelrget_safe_value)rr-s r!r4zMixedObject.get_safe_valueBs6 i &&557 7&&55g> >r"c.|jjSr)r array_typer,s r!r6zMixedObject.array_typeHs""---r"c6|jjSr)rget_key_valuesr,s r!r8zMixedObject.get_key_valuesLs""1133r"c|jjjj}t |t vr|jj |S|jj |Sr)rraccess_objtyperpy__simple_getitem__r&)rindex python_objects r!r=z MixedObject.py__simple_getitem__Os[++99@@EE  "7 7&&;;EB B""77>>r"c6|jjSr)rnegater,s r!rAzMixedObject.negateUs""))++r"cF|j t|St|Sr)parent_contextMixedModuleContext MixedContextr,s r! _as_contextzMixedObject._as_contextXs$    &%d+ +D!!r"cdt|jd|jjd|jdS)N)r<__name__rget_reprr&r,s r!__repr__zMixedObject.__repr__]s4 J      ' ' )     r")rJ __module__ __qualname____doc__rr)r+rr r/r3r4propertyr6r8r=rArFrL __classcell__r s@r!rrsh : L4 ")4,5,&/? ..4? ,"  r"rceZdZedZy)rEc.|jjSr)_valuerr,s r!rzMixedContext.compiled_valuefs{{)))r"N)rJrMrNrPrr"r!rErEes **r"rEc eZdZy)rDN)rJrMrNrVr"r!rDrDksr"rDcBeZdZdZfdZedZedZxZ S) MixedNamezB The ``CompiledName._compiled_value`` is our MixedObject. c2t||||_yr)rr_parent_tree_value)r wrapped_nameparent_tree_valuer s r!rzMixedName.__init__ss &"3r"clt|j}|sy|djjS)N)rrr)listinfername start_pos)rr1s r!rbzMixedName.start_posws,djjl#ay~~'''r"c |jj}|j}|js|j rN|j |j }|jr#t|Dchc]}t||c}S|j}t|j||Scc}wr) _wrapped_nameinfer_compiled_valuer[ is_instanceis_classpy__getattribute__ string_name is_functionr rget_root_context_create_inference_state)rrr tree_valuesvmodule_contexts r!r`zMixedName.infers++@@B,,  ! ! #z':':'<$778H8HIK))+ UA^Q!? UVV#446t,,nnMM!Vs;B<) rJrMrNrOrrPrbrr`rQrRs@r!rYrYos74(( N Nr"rYc(eZdZfdZfdZxZS)r$c4t|||||_yr)rr _tree_value)rr%rrr s r!rzMixedObjectFilter.__init__s .9%r"cJtt||i||jSr)rYr _create_namers)rr'r(r s r!ruzMixedObjectFilter._create_names+ G $ 1& 1     r")rJrMrNrrurQrRs@r!r$r$s&  r"r$c|j|dtjtjj S)NT)pathcache diff_cache cache_path)parser fast_parsercache_directory get_root_node)r%rws r! _load_modulers;  ''++ !  mo r"c tj|}tj|s~tj|sitj |sTtj |s?tj|s*tj|stj|r|S |jS#t$rYwxYw#t$rtwxYw)z9Check if inspect.getfile has a chance to find the source.) inspectunwrap ValueErrorismoduleisclassismethod isfunction istracebackisframeiscoder AttributeError TypeError)r?s r!_get_object_to_checkrs }5 '}- .!!-0""=1}-~~m,&&&     sB9- C9 CCCc|} t|}tj|}|dn t |} ||j sy t|}t||}tj|rt|j|}||||fS |j}|dk(ry|jj|g}|D cgc]5} | j j"dvr| j j$| k(r| 7}} |sy |j&} | j(} |D cgc]} | j*d| k(s| } } | r| } t|j|}|dj }|j"dk(rt-|dk(ry||||fS#ttf$rYywxYw#t$rYywxYw#t$rYywxYwcc} wcc} w#t$rYwxYw)Nz)funcdefclassdefrrinstance)rr getsourcefileOSErrorrrexistsrrrrgrammarrJrget_used_namesgetparentr<ra__code__co_firstlinenorbr)r%r?original_objectrwfile_io module_node code_linesname_strnamesncodeline_nrra line_names tree_nodes r!_find_syntax_node_namers#O,]; $$]3<4T$ZD  '>EJ b   I~~"|O'D 'R  7J 66U Y    &  "N    sX FF$ F3:GG #G;GF! F!$ F0/F03 F?>F? GGc jjj}t||}|Bt |t t tfvr thSt}|s thS|\}}}} ||j|k7rjj} | j} t| jd} t|||| | | j!} | &|j"j%| t| g| j'}t|j)|h}|jdk(r j+s|j-}tfd|DS)N.)r string_namesr is_packagerc38K|]}t|yw))rN)r).0rrs r! z_create..2s#  Nz::s)rr:r;rr<dictr_tupler rrrk get_value py__name__splitr r module_cacheadd as_context create_valuergexecute_with_values)r%rrpr?resultrnrrrrroot_compiled_valuerar module_values ` r!rlrl sr#0077<>Z '!**,)==? % r").rOrpathlibrjedi.parser_utilsrjedir jedi.cacherjedi.inferencer jedi.file_iorjedi.inference.namesr jedi.inference.base_valuer r r jedi.inference.valuer jedi.inference.cacherrjedi.inference.compiled.accessrr!jedi.inference.gradual.conversionrjedi.inference.contextrrrobjectr3rrErDrYCompiledValueFilterr$rrrrlrVr"r!rs3%#,GG,!N5 H G ,G T*?$4*  .  N N:  44   !".O7d !)")r"