TL iD>(dZddlmZddlmZmZmZddlmZm Z m Z ddl m Z ddl mZmZddlmZddlmZmZdd lmZmZdd lmZmZmZdd lmZdd lmZdd l m!Z!m"Z"ddl#m$Z$GddeZ%GddeZ&GddZ'Gdde'ee Z(y)a Like described in the :mod:`parso.python.tree` module, there's a need for an ast like module to represent the states of parsed modules. But now there are also structures in Python that need a little bit more than that. An ``Instance`` for example is only a ``Class`` before it is instantiated. This class represents these cases. So, why is there also a ``Class`` class here? Well, there are decorators and they change classes in Python 3. Representation modules also define "magic methods". Those methods look like ``py__foo__`` and are typically mappable to the Python equivalents ``__call__`` and others. Here's a list: ====================================== ======================================== **Method** **Description** -------------------------------------- ---------------------------------------- py__call__(arguments: Array) On callable objects, returns types. py__bool__() Returns True/False/None; None means that there's no certainty. py__bases__() Returns a list of base classes. py__iter__() Returns a generator of a set of types. py__class__() Returns the class of an instance. py__simple_getitem__(index: int/str) Returns a a set of types of the index. Can raise an IndexError/KeyError. py__getitem__(indexes: ValueSet) Returns a a set of types of the index. py__file__() Only on modules. Returns None if does not exist. py__package__() -> List[str] Only on modules. For the import system. py__path__() Only on modules. For the import system. py__get__(call_object) Only on instances. Simulates descriptors. py__doc__() Returns the docstring for a value. ====================================== ======================================== )debug)get_cached_parent_scopeexpr_is_dottedfunction_is_property)inference_state_method_cacheCachedMetaClass&inference_state_method_generator_cache)compiled)LazyKnownValues LazyTreeValue)ParserTreeFilter)TreeNameDefinition ValueName)unpack_arglistValuesArguments)ValueSetiterator_to_value_set NO_VALUES ClassContext)FunctionAndClassBase)LazyGenericManagerTupleGenericManager)plugin_managercBeZdZfdZedZefdZxZS) ClassNamecBt|||||_||_yN)super__init___apply_decorators _class_value)self class_value tree_name name_contextapply_decorators __class__s `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/jedi/inference/value/klass.pyr zClassName.__init__:s" y1!1'c#Kddlm}||jj|j|j}|D]8}|j r&|j d|jEd{5|:y7 w)Nr)tree_name_to_values)instancer$)jedi.inference.syntax_treer,parent_contextinference_stater%r! py__get__r")r#r,inferred result_values r)inferzClassName.infer?sv C&    / /1D1DdnnV% #L%%'114TM^M^1___""  #_sA*A;,A9- A;czt|}|dk(r*|jj}||St |ry|S)Nfunctionproperty)rapi_typer%get_definitionr)r#type_ definitionr(s r)r8zClassName.api_typeLsD  J 668J! #J/ " r*) __name__ __module__ __qualname__r rr4r7r8 __classcell__r(s@r)rr9s0(  # #  r*rc@eZdZ dfd ZdZdZdZfdZxZS) ClassFiltercdt||j|||||_||_y)N)until_position origin_scope)rr as_contextr" _is_instance)r#r$ node_contextrDrE is_instancer(s r)r zClassFilter.__init__^s;   " " $l)%  ('r*c |Dcgc]0}t|j||j|j 2c}Scc}w)N)r$r%r&r')rr" _node_contextrG)r#namesnames r)_convert_nameszClassFilter._convert_nameshsL    --!//%)%6%6!6     s5=c|j}|8||jk(s||jk(ryt|j|}|8y)NTF) _origin_scope _parser_scoper/r_parso_cache_node)r#nodes r)_equals_origin_scopez ClassFilter._equals_origin_scopersP!!t)))TT5H5H-H*4+A+A4HDr*c|jjd xs-|jjdxs|jS)N__)value startswithendswithrT)r#rMs r)_access_possiblezClassFilter._access_possiblezsC::((..+$**2E2Ed2K+((* +r*cpt||}|Dcgc]}|j|s|c}Scc}wr)r_filterrZ)r#rLrMr(s r)r\zClassFilter._filters2&!&F$*?*?*EFFFs33)NNNF) r<r=r>r rNrTrZr\r?r@s@r)rBrB]s)FJ05( + GGr*rBceZdZdZdZdZdZedZdZ e dZ dd Z d Z d Zdd Zed dZdZdZdZy) ClassMixincyNTr#s r)is_classzClassMixin.is_classr*cyr`rarbs r)is_class_mixinzClassMixin.is_class_mixinrdr*cddlm}ddlm}|j rt ||gSt ||j |j||gS)Nr) TreeInstance) TypedDict)jedi.inference.valuerhjedi.inference.gradual.typingri is_typeddictrr0r/)r# argumentsrhris r) py__call__zClassMixin.py__call__sM5;    Yt_-. .d&:&:D*>GGr*cBt||jjSr)r tree_noderMrbs r)rMzClassMixin.namest~~2233r*c.|jjSr)rM string_namerbs r) py__name__zClassMixin.py__name__syy$$$r*c#"K|g}||jD]J}|jD]5} |j}|D]}||vs|j||7Ly#t$r t j d||Y^wxYww)Nz$Super class of %s is not a class: %s) py__bases__r4 py__mro__appendAttributeErrorrwarning)r#mrolazy_clscls mro_methodcls_news r)rzzClassMixin.py__mro__sf ((* *H ~~' **!$J$.<*"#-JJw/")M*' * *& U MM"H$PST Us-.B A(B B(!B  B B  BNFc#VK|r,|j}|r|j||Ed{|jD]L}|jr|j |Ed{.t ||j ||N|s|rddlm}||jd}t|tsJ||k7r^tg} |j| D]>} | j } t| dt| dt| d} | J| @yyyy77w)N)rI)rHrErIr)rqrp)get_metaclassesget_metaclass_filtersrz is_compiled get_filtersrBrFjedi.inference.compiledrqr0 isinstance ClassValuerrnnext) r#rErIinclude_metaclassesinclude_type_when_class metaclassesrrqr:argsr-instance_filtersxs r)rzClassMixin.get_filterss7 ..0K55k;OOO>># C ??{?CCC!s~~'7!- +  6 A%d&:&:FCEeZ0 00}'r* % 0 0 6H'/';';'=$)40)40-t4A=(=G  7{PDs"*D)D%2 $ --Fx# $ $.&!! !s( B BBcddlm|s!tjdt gSt fd|DS)Nr GenericClassz:Class indexes inferred to nothing. Returning class insteadc3ZK|]"}tj|$yw))context_of_index index_valueN)rcontext).0rrcontextualized_noder#s r) z+ClassMixin.py__getitem__..s7   "%8%@%@ +   s(+)jedi.inference.gradual.baserrr}r)r#index_value_setrrs` `@r) py__getitem__zClassMixin.py__getitem__s?< MMV WTF# #   /   r*c2ddlm}||t|S)Nrr)rrr)r#generics_tuplers r) with_genericszClassMixin.with_generics#s<   /  r*c ddlm}fd}r*t|tt |gSthS)Nrrc3KjD](}j|jt*yw)aa The TypeVars in the resulting classes have sometimes different names and we need to check for that, e.g. a signature can be: def iter(iterable: Iterable[_T]) -> Iterator[_T]: ... However, the iterator is defined as Iterator[_T_co], which means it has a different type var name. N)list_type_varsgetrwr)type_varr# type_var_dicts r)remap_type_varsz3ClassMixin.define_generics..remap_type_vars-s?!//1 J#''(;(;(=yII Js=A)rrrrtuple)r#rrrs`` r)define_genericszClassMixin.define_generics*sL< J \#E/*;$<= r*)NFTT)T)r<r=r>rcrfrnrrr7rMrwr rzrrrrrrlrrrrar*r)r^r^sdH44%,-*.*@:?FJ D G"! "%01:   r*r^ceZdZdZedZdZeddZejdZ ee dZ ejd Z y ) rclasscg}|jj}|gSt|D]<\}}|r ddlm}||j |D]}||vs|j |>|S)Nr)find_unknown_type_vars)rtget_super_arglistr!jedi.inference.gradual.annotationrr/r{)r#foundargliststarsrSrrs r)rzClassValue.list_type_varsEs{..224 ?I)'2 +KE4 P243F3FM +5(LL* +  + r*c|jj}|r-ddlm}|j |j |j |Sy)Nr)rm)rtrjedi.inferencerm TreeArgumentsr0r/)r#rrms r)_get_bases_argumentszClassValue._get_bases_argumentsWs?..224  0**4+?+?ATATV]^ ^r*rarc@|j}|)|jDcgc] \}}| | }}}|r|S|jdk(r|jj rgSt |j jjdgScc}}w)Nobject) runpackrwr/is_builtins_moduler r0builtins_moduler)r#rkeyrWlsts r)ryzClassValue.py__bases__^s((*  +/;;=HZS%CK5HCH ??  (''::<I  0 0 C CH M   Is BBc2tjd|gS)NzUnprocessed metaclass %s)rr})r#rrIs r)rz ClassValue.get_metaclass_filtersms 0+> r*c|j}|Z|jDcgc] \}}|dk(s |}}}tjd|D}td|D}|r|S|j D]@}|j D]+}|j s|j}|s'|ccSBtScc}}w)N metaclassc3<K|]}|jywr)r4)r lazy_values r)rz-ClassValue.get_metaclasses..ws,TJZ-=-=-?,Tsc3BK|]}|js|ywr)rc)rms r)rz-ClassValue.get_metaclasses..xs"JQZZ\1"Js) rrr from_setsryr4rcrr)r#rrrWrr lazy_basevaluess r)rzClassValue.get_metaclassesrs((*  )-M:3#:LMAM",,,TRS,TTK""Jk"JJK""))+ &I"* &>>#"224F%  & & Ns CCcgSrra)r#rs r)rz#ClassValue.get_metaclass_signaturess r*N)r<r=r>r8rrrryrdecoraterrrrrar*r)rrBsH!#$"""-  .  ^")45"^r*r)rN))__doc__jedirjedi.parser_utilsrrrjedi.inference.cacherrr rr jedi.inference.lazy_valuer r jedi.inference.filtersr jedi.inference.namesrrjedi.inference.argumentsrrjedi.inference.base_valuerrrjedi.inference.contextrjedi.inference.value.functionrjedi.inference.gradual.genericsrr jedi.pluginsrrrBr^rrar*r)rs%L++#D3>D/>S'!"!H$G"$GN{ { |D1_Dr*