Vcc sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z m Z gdZ GddeZGddZeZGdd ZeZGd d ZeZejiZGd d ZedZedZedZdZdZdZejdZ GddZ!GddZ"GddZ#eedddddeddZ$dZ%dZ&d Z'dded!d"Z(d#Z)d$Z*d%Z+d&Z,d'Z-d(Z.d)Z/d*Z0d+Z1d,Z2d-Z3d.Z4d/Z5d0Z6d1Z7d2Z8d3Z9d4Z:id5dd6dd7dd8dd9e8d:dd;e9de:d?e9d@e:dAe9dBe:dCe9dDe:Z;dEZdHZ?dIZ@dZddddJdJdJddJdJdJdK dLZAdMZBdNZCdOZDeEdPdQZFdRZGeHdSdTZIdUZJdVdddddJdJdJddJdJdJdW dXZKdYZLdS)[N) FunctionType GenericAlias) dataclassfieldFieldFrozenInstanceErrorInitVarKW_ONLYMISSINGfieldsasdictastuplemake_dataclassreplace is_dataclassceZdZdS)rN__name__ __module__ __qualname__$/usr/lib64/python3.11/dataclasses.pyrrsrrcseZdZdZdS)_HAS_DEFAULT_FACTORY_CLASScsdS)Nz rself r__repr__z#_HAS_DEFAULT_FACTORY_CLASS.__repr__s{rN)rrrrrrrrrs#rrcr) _MISSING_TYPENrrrrrrDrrcr) _KW_ONLY_TYPENrrrrrrrrrcseZdZdZdZdS) _FIELD_BASEc||_dSNnamerr$ r__init__z_FIELD_BASE.__init__  rcs|jSr"r#rrrrz_FIELD_BASE.__repr__s yrN)rrrr'rrrrr r s2rr _FIELD_FIELD_CLASSVAR_FIELD_INITVARZ__dataclass_fields__Z__dataclass_params__Z __post_init__z^(?:\s*(\w+)\s*\.)?\s*(\w+)cs$eZdZdZdZdZdZdS)rtypecr!r"r,)rr-r&rr'zInitVar.__init__r(rcst|jtr |jj}nt|j}d|dS)Nzdataclasses.InitVar[z]) isinstancer-rrepr)rZ type_namer&rrzInitVar.__repr__sB di & & ( *IITYI2i2222rcs t|Sr")r)clsr-r&r__class_getitem__zInitVar.__class_getitem__st}}rN)rrr __slots__r'rr1rrrrrsFI333rrcs:eZdZdZdZdZdZeeZ dS)r) r$r-defaultdefault_factoryr/hashinitcomparemetadatakw_only _field_typec sd|_d|_||_||_||_||_||_||_|tntj ||_ ||_ d|_ dSr")r$r-r3r4r6r/r5r7_EMPTY_METADATAtypesMappingProxyTyper8r9r:) rr3r4r6r/r5r7r8r9 rr'zField.__init__ ss   .    $:/99  rcsd|jd|jd|jd|jd|jd|jd|jd|jd |jd |j d |j d S) Nz Field(name=z,type=z ,default=z,default_factory=z,init=,repr=z,hash=z ,compare=z ,metadata=z ,kw_only=z ,_field_type=)) r$r-r3r4r6r/r5r7r8r9r:rrrrzField.__repr__s        <  $(#7            <  !M   <   $/    rcsxtt|jdd}|r||j||dSdS)N __set_name__)getattrr-r3)rZownerr$Zfunc rrAzField.__set_name__2sMtDL))>4@@  , Dud + + + + + , ,rN) rrrr2r'rrAZ classmethodrr1rrrrrsV I     .,,,$ L11rrcseZdZdZdZdZdS)_DataclassParamsr6r/eqorder unsafe_hashfrozencsZ||_||_||_||_||_||_dSr"rE)rr6r/rFrGrHrI rr'z_DataclassParams.__init__Es1   & rc shd|jd|jd|jd|jd|jd|jd S)Nz_DataclassParams(init=r?z,eq=z,order=z ,unsafe_hash=z,frozen=r@rErrrrz_DataclassParams.__repr__Mst  g  $/  +  rN)rrrr2r'rrrrrDrD<s9IrrDTr3r4r6r/r5r7r8r9c sp|tur|turtdt||||||||S)aReturn an object to identify dataclass fields. default is the default value of the field. default_factory is a 0-argument function called to initialize a field's value. If init is true, the field will be a parameter to the class's __init__() function. If repr is true, the field will be included in the object's repr(). If hash is true, the field will be included in the object's hash(). If compare is true, the field will be used in comparison functions. metadata, if specified, must be a mapping which is stored but not otherwise examined by dataclass. If kw_only is true, the field will become a keyword-only parameter to __init__(). It is an error to specify both default and default_factory. z/cannot specify both default and default_factory)r ValueErrorrrK rrr[sQ$gL/"@LJKKK /4tW7 $ $$rcsftd|Dtd|DfS)Nc3s6K|]}|j |j|VdSr"r6r9.0fr&r (_fields_in_init_order..ws0@@qv@ai@!@@@@@@rc3s6K|]}|j |j|VdSr"rNrOr&rrRrSxs0<<qvz_tuple_str..s)@@@AH//qv//@@@r,))join)r[r s` r _tuple_strr`|sD t Esxx@@@@@@@AA E E EErcsfttjfd}|S)Ncst|tjf}|vrdS| |}|n#|wxYw|S)Nz...)Zid_threadZ get_identaddZdiscard)rZkeyresult repr_running user_functions rwrapperz _recursive_repr..wrappershh)+++ ,  5 &"]4((F   % % % %L  % % % % s A!!A8)set functoolsZwraps)rerfrds` @r_recursive_reprrisI55L_]##     $#  Nr)globalslocals return_typecst|i}d|vr t|d<d}|tur||d<d}d|}dd|D}d|d |d |d |}d |}d |d|d|}i} t ||| | ddi|S)NZBUILTINSZ _return_typez->_return_typerYz c3s K|] }d|V dS)z Nr)rPbr&rrRz_create_fn..s(,,!X!XX,,,,,,rz def rXr@z: , zdef __create_fn__(z): z return Z __create_fn__r)builtinsr r_ZkeysZexec) r$ZargsZbodyrjrkrlZreturn_annotationZtxtZ local_varsnss r _create_fnrrs  &%z'!-!,~, 88D>>D 99,,t,,, , ,D =$ < < < < 1 < z_init_fn..&s' 8 8 8Aqv 8 8 8r)r _HAS_DEFAULT_FACTORYrYc3s@K|]}|jtu|jVdSr")r:r+r$rOr&rrRz_init_fn..6sLBB!".!@BafBBBBBBrrZrXr@Zpassc,g|]}t|SrrxrOr&rr]_init_fn..>s777qKNN777rZ*crzrr{rOr&rr]r|Ds@@@AQ@@@rr')rkrjrl) r6r3r r4 TypeErrorr$updateryrwappendr__POST_INIT_NAMErr)r Z std_fieldsZkw_only_fieldsrI has_post_initrtrjrvZ seen_defaultrQrkZ body_linesZlineZ params_strZ _init_paramss r_init_fnrsL << 6 <I( '-I <#  <!;!;!;!;<<<9 8 8 8 8F MM 4 J $$1ffi??  $   d # # #JXXBBfBBBBB YHHHH:HHHIII X 77J777LA  @@@@@@ j kL0 #%"&  ( ( ((rc stddddd|Dzdzg|}t|S)Nrrz(return self.__class__.__qualname__ + f"(rocs2g|]}|jd|jdS)z={self.z!r}r#rOr&rr]z_repr_fn..Qs= 1 1 1$%$%6 ? ?16 ? ? ? 1 1 1rz)"rj)rrr_ri)r rjfn r_repr_fnrMst J?YY 1 1)/ 1 1 1222%  & & &B 2  rcs|td}|r&ddd|Dzdz}nd}tddd |d d d f|| tddd |d ddf|| fS)N)r0rrXrYc3s>K|]}t|jVdSr")r/r$rOr&rrRz'_frozen_get_del_attr..\s*#A#AQDLL#A#A#A#A#A#Arr^rW __setattr__)rr$rsz if type(self) is cls or name in z:z> raise FrozenInstanceError(f"cannot assign to field {name!r}")z)super(cls, self).__setattr__(name, value))rkrjZ __delattr__r%z; raise FrozenInstanceError(f"cannot delete field {name!r}")z"super(cls, self).__delattr__(name))rr_rr)r0r rjrkZ fields_str r_frozen_get_del_attrrXs%8::F 388#A#A&#A#A#AAAADH  }/G*GGGXCE%&  ( ( ( }&G*GGGU<>%&  ( ( ( rc s<t|ddd|||dg|S)N)rotherz%if other.__class__ is self.__class__:z return zreturn NotImplementedr)rr)r$op self_tuple other_tuplerjrr_cmp_fnrqsE d'??*?b?+??/1&  ' ' ''rcsRtd|}tddd|dg|S)Nr__hash__rz return hash(r@r)r`rr)r rjrrr_hash_fnrsAFF++J j3j3334% ' ' ''rcs\||jup#t||juo |j|juSr")ClassVarr-Z _GenericAliasZ __origin__)a_typetypingr&r _is_classvarrs; fo % :V  449%8;rcs@||jupt||juSr")rr-r dataclassesr&r _is_initvarrs* k) ) 3F||{224rcs||juSr")rrr&r _is_kw_onlyrs [( ((rcst|}|rd}|d}|s*tj|jj}nktj|j}|rE|j||ur)tj|jj}|r4|||d|rdSdS)NTF)_MODULE_IDENTIFIER_REmatchZgroupsysmodulesgetr__dict__) Z annotationr0Za_modulerZis_type_predicaterrqZ module_nameZmoduler>r_is_typersR " ' ' 3 3E  kk!nn  A009BB[__S^44F A&/--k::hF A[__V%677@  ##BFF5;;q>>$:$:HEE 4 5rcst||t}t|tr|}n1t|tjrt}t |}||_||_t|_ tj d}|rXt||s|jjj-t;dt|jd|jd|S) N)r3rfield z cannot have a default factoryz$ is a ClassVar but specifies kw_onlyzmutable default z for field z$ is not allowed: use default_factory)rBr r.rr<ZMemberDescriptorTyperr$r-r)r:rrrrstrrrr*rrrr+r4r}r9r3 __class__rrL)r0Za_namerZdefault_kw_onlyr3rQrrrMr _get_fieldrsyc67++G'5!!#  gu9 : : G ' " " "AF AF AM [__X & &F ,  ( ( ,163'' ,QVS&&/)++ ,,AM }+k(+  , , +163'' +QVS+{7J(** ++AM }.99/ G + /.QV...// / }00 ' 9  ('AI 9G # '&QV&&&'' '  }J19#6#?JIDOOIIFIIIJJ J Hrcs\t|tr|jd|j|_|S)NrZ)r.rrr)r0rsr&r _set_qualnamer5s7%&&D # 0CC5>CC Lrcs^||jvrdSt||t|||dS)NTF)rrsetattr)r0r$rsrr_set_new_attributer<s? s|t#u Cu 5rcsdSr"rr0r rjrr_hash_set_nonerKs 4rcsVd|D}t|t||S)Ncs>g|]}|j|jn|j|Sr")r5r7rOr&rr]z_hash_add..Os0 K K K!qv K!) K K16 KA K K Kr)rr)r0r rjfldsrCr _hash_addrNs/ K Kv K K KD htW55 6 66rcs0td|j)Nz-Cannot overwrite attribute __hash__ in class )r}rrrr_hash_exceptionrRs( / # // 0 00r)FFFF)FFFT)FFTF)FFTT)FTFF)FTFT)FTTF)FTTT)TFFF)TFFT)TFTF)TFTT)TTFF)TTFT)TTTF)TTTTc sj i} |jtjvrtj|jj} ni} t |t t ||||||d} d}|jdddD]Y}t|td}|?d}| D] }|| |j < t|t j rd} Z|j di}g}d}tjt}|D]\}}t!||s2t#|t$r6t'||||jt r|rt+|dd}d}`|t/|||||D]t}|| |j <t#t||j dt0r?|jt4urt7||j Yt ||j |ju|jD]0\}}t#|t0r||vrt+|d1|r&| r|st+d| s|rt+d t |t| |j d t4}|t4up |duod |jv }|r|st9d d | D}t;|\}}|r@t=|t>}tA|dtC|||||d| vrdnd| | d| D}|r+d|D} tA|dtE| | |rOd|D} tGd| }!tGd| }"tA|d tId d|!|"| |rrd|D} tGd| }!tGd| }"dD]C\}}#tA||tI||#|!|"| rt+d|d|jdD|rItK||| D]7}$tA||$j|$rt+d|$jd|j8tLtO|tO|tO||f}%|%r|%||| |_(t|dsB|jt%tSj*|+ddz|_,|r(tA|d t[d!|D| r| st+d"| rt]||| }t_j0||S)#NFrT__annotations__z3 is KW_ONLY, but KW_ONLY has already been specifiedz& is a field but has no type annotationz5cannot inherit non-frozen dataclass from a frozen onez5cannot inherit frozen dataclass from a non-frozen onerZ__eq__z eq must be true if order is truecs<g|]}|jttfv|Sr)r:r)r+rOr&rr]"_process_class..s?EEEQ-FN+CCEqEEErr'rZ__dataclass_self__cs.g|]}|jtu|Srr:r)rOr&rr]rs$HHH 0GH!HHHrc g|] }|j | Sr)r/rOr&rr]rs000a0000rrcrrr7rOr&rr]r333a3333rrz==rcrrrrOr&rr]r'rr))Z__lt__z<)Z__le__z<=)Z__gt__z>)Z__ge__z>=zCannot overwrite attribute z in class z). Consider using functools.total_ordering__doc__z -> NonermZ__match_args__c3$K|] }|jV dSr"r#rOr&rrRz!_process_class..Ns$ A AA A A A A A Arz'weakref_slot is True but slots is False)1rrrrr_PARAMSrD__mro__rB_FIELDSvaluesr$rIrritemsrr.rrrr}rrrr3r ZdelattrrLrVhasattrrrrrr`rr _hash_actionZboolrinspectZ signaturerrrT _add_slotsabcZupdate_abstractmethods)&r0r6r/rFrGrHrI match_argsr9rv weakref_slotr rjZany_frozen_baseZhas_dataclass_basesrnZ base_fieldsrQZcls_annotationsZ cls_fieldsZ KW_ONLY_seenrr$r-rsZ class_hashZhas_explicit_hashZall_init_fieldsZstd_init_fieldsZkw_only_init_fieldsrZ field_listrrrrrZ hash_actions& r_process_classrusc F ~$+cn-6 C*4r5+6@@AAAO [Ab ! ' 'a$//  '"&  '')) # #!"qvq'"") '"&l&&'8"==O JL+h'K%++--DD d k * * D4%% DT3 [5H(** D  >4!=!=!=>>>LGG   jdD'BB C C C C 00qv gc16400% 8 8 0yG# 0QV$$$$QVQY///|))++OO e eU # # ODO,C OtMMMNN N .  *6 *)** * .6 .-.. .  C&!!!!!*g66J'72O(D0MX5MP  =R=;<<< EE&--//EEEO2/BB_ _55 3 #O$3$7$*$1=Cf.`s% 8 8 8aGD!& ! ! 8 8 8rrUrs`r_dataclass_getstater_s# 8 8 8 86$<< 8 8 88rcstt||D]&\}}t||j|'dSr")Zzipr Zobjectrr$)rZstaterrsrCr_dataclass_setstatercsLF4LL%0044 u4U333344rc#sK|jdxdSxtdx \}|VdS}t|ds |Ed{VdS t d|jd)Nr2rZ__next__z Slots of 'z' cannot be determined)rrrrr}r)r0ZslotZiterablerr _get_slotsris ,  ; ' ' TT F SYYYYYJJJJJWXz::X          MMMMNN Nrc sd|jvrt|jdt|j}t dt |D}t tj tt|j dd}t tj |jtj||rdnd|d<|D]}||d|ddt!|d d}t#||j|j|}|||_|rt(|_t,|_|S) Nr2z already specifies __slots__c3rr"r#rOr&rrRz_add_slots..s$441444444rrr)Z __weakref__rrr)rr}rdictrTr rg itertoolsZchainZ from_iterableZmaprrZ filterfalseZ __contains__ZpoprBr-Z __bases__rrZ __getstate__rZ __setstate__)r0Z is_frozenrZcls_dictZ field_namesZinherited_slotsZ field_nameZqualnamerMrrrws cl"G3<EEEFFFCL!!H44s 44444K%%c*ck!B$6G&H&HIIO "  ( OE--2      H["''   Z&&&& LLT"""sND11H $s))CL#- : :C$#/.. JrF r6r/rFrGrHrIrr9rvrc sP   f d} || S| |S)aAdd dunder methods based on the fields defined in the class. Examines PEP 526 __annotations__ to determine fields. If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, a new class with a __slots__ attribute is returned. c s6 t|  Sr")r) r0rFrIr6r9rrGr/rvrHrs rwrapzdataclass..wraps-c4r5+$j'5*,, ,rr) r0r6r/rFrGrHrIrr9rvrrs `````````` rrrsq",,,,,,,,,,,,,,    499rcs t|t}n#t$rtdwxYwt d|DS)zReturn a tuple describing the fields of this dataclass. Accepts a dataclass or an instance of one. Tuple elements are of type Field. z0must be called with a dataclass type or instancec3s6K|]}|jtu|VdSr"rrOr&rrRzfields..s.GGqq}/FGGGGGGGr)rBrAttributeErrorr}rTr)Zclass_or_instancer r&rr r soL*G44 LLLJKKKL GGFMMOOGGG G GGs2csFtt|tS)z2Returns True if obj is an instance of a dataclass.)rr-r)objrr_is_dataclass_instancers 499g & &&rcsxt|tr|nt|}t|tS)zEReturns True if obj is a dataclass or an instance of a dataclass.)r.r-rr)rr0r&rrrs2C&& 5##DIIC 3  r) dict_factoryc^t|stdt||S)aReturn the fields of a dataclass instance as a new dictionary mapping field names to field values. Example usage:: @dataclass class C: x: int y: int c = C(1, 2) assert asdict(c) == {'x': 1, 'y': 2} If given, 'dict_factory' will be used instead of built-in dict. The function applies recursively to field values that are dataclass instances. This will also look into built-in containers: tuples, lists, and dicts. z0asdict() should be called on dataclass instances)rr} _asdict_inner)rrr&rr r s4& "# & &LJKKK l + ++rcst|r^g}t|D]A}tt||j}||j|fB|St |tr.t|drt|fd|DSt |ttfr$t|fd|DSt |tr6t|fd| DStj|S)N_fieldsc0g|]}t|SrrrPvrr\rr]z!_asdict_inner..s#GGGa=L99GGGrc38K|]}t|VdSr"rrr\rrR _asdict_inner..s-EEAq,77EEEEEErc3^K|]'\}}t|t|fV(dSr"r)rPkrr rrRr sW22!Q(<88'<88:222222r)rr rrBr$rr.rTrr-listrrcopydeepcopy)rrrcrQrs ` rrrsoc""%" + +A!'#qv"6"6 EEE MM165/ * * * *|F### C  "GC$;$;"(tCyyGGGG3GGGHH C$ ' ' "tCyyEEEEEEEEEE C  "tCyy2222%(YY[[22222 2}S!!!r) tuple_factorycr)aReturn the fields of a dataclass instance as a new tuple of field values. Example usage:: @dataclass class C: x: int y: int c = C(1, 2) assert astuple(c) == (1, 2) If given, 'tuple_factory' will be used instead of built-in tuple. The function applies recursively to field values that are dataclass instances. This will also look into built-in containers: tuples, lists, and dicts. z1astuple() should be called on dataclass instances)rr}_astuple_inner)rrr&rr r 's4& "# & &MKLLL #} - --rcst|rWg}t|D]:}tt||j}||;|St |tr.t|drt|fd|DSt |ttfr$t|fd|DSt |tr6t|fd| DStj|S)NrcrrrrPrrr\rr]z"_astuple_inner..Ms#III>!];;IIIrc3rr"rrr\rrR!_astuple_inner..Rs-GGa=99GGGGGGrc3rr"r)rPrrrrrrRrTsT33"a)M::N1m<\<\]333333r)rr rrBr$rr.rTrr-rrrrr)rrrcrQrsrrrr?sic""" ! !A"73#7#7GGE MM% }V$$$ C  "GC$;$;"tCyyIIIISIIIJJ C$ ' ' "tCyyGGGG3GGGGGG C  "tCyy3333&)iikk33333 3}S!!!rr) bases namespacer6r/rFrGrHrIrr9rvrc sit}ii|D]}t|tr|}d}nJt|dkr|\}}n1t|dkr |\}}}||<nt d|t|tr|st d|t j|rt d|||vrt d|||||<fd }tj ||i|}t||||||| | | | | S) aReturn a new dynamically created dataclass. The dataclass name will be 'cls_name'. 'fields' is an iterable of either (name), (name, type) or (name, type, Field) objects. If type is omitted, use the string 'typing.Any'. Field objects are created by the equivalent of calling 'field(name, type [, Field-info])'.:: C = make_dataclass('C', ['x', ('y', int), ('z', int, field(init=False))], bases=(Base,)) is equivalent to:: @dataclass class C(Base): x: 'typing.Any' y: int z: int = field(init=False) For the bases and namespace parameters, see the builtin type() function. The parameters init, repr, eq, order, unsafe_hash, and frozen are passed to dataclass(). Nz typing.AnyrizInvalid field: z'Field names must be valid identifiers: z"Field names must not be keywords: zField name duplicated: csf|||d<dS)Nr)r~)rq annotationsdefaultsrs rexec_body_callbackz*make_dataclass..exec_body_callbacks8 ) ( + rr) rgr.rZlenr}Z isidentifierkeywordZ iskeywordrbr<Z new_classr)Zcls_namer rrr6r/rFrGrHrIrr9rvrZseenZitemr$ZtpZspecrr0rrs ` @@rr r Zs6  55DKH dC 8DBB YY!^ 8ID"" YY!^ 8!ND"d!HTNN6d6677 7$$$ PD,=,=,?,? PNdNNOO O  T " " KIIIJJ J 4< @>d>>?? ?  D,,,,,,, /(E2/A B BC St$2U!,V *G5". 0 0 00rc st|stdt|tD]}|jt ur|js"|j|vrtd|jd:|j|vrQ|jtur&|j turtd|jdt||j||j<|j di|S)a+Return a new object replacing specified fields with new values. This is especially useful for frozen classes. Example usage:: @dataclass(frozen=True) class C: x: int y: int c = C(1, 2) c1 = replace(c, x=3) assert c1.x == 3 and c1.y == 2 z1replace() should be called on dataclass instancesrzC is declared with init=False, it cannot be specified with replace()zInitVar z! must be specified with replace()r)rr}rBrrr:r*r6r$rLr+r3r r)rZchangesrQrrrrs6$ "# & &MKLLL S' " " ) ) + +33 =O +  v v  . "-!&"-"-"-...  6  3}. E193G E "DAF"D"D"DEEE%c1622GAFO 3= # #7 # ##rr")MZrerrr<rrrprhrrrarrZ__all__rrrryrr rrr=r;r r)r*r+rrrZcompilerrrrDrrVr`rirrrurwrxrrrrrrrrrrrrrrrrrrrrrrr rrrr rrTr rr rrrrrs!  ,,,,,,,,   |0////./// 2133        -//        -//)%(,, X  +/00-.. ! !" # #ABB6<2<2<2<2<2<2<2<2~>gDtTD'$$$$$0 F F F&-1")))))4 ) ) )9;9;9;x///&8(8(8(v2 ' ' '''';;;444 )))888v_ _ _ B777000,d,d,d-d-n  -d  -i -d-i-o-i-o-i-o-i-o *cccT999444 O O O///d4dt5$5u>HHH$''' !!!!%,,,,,0&"&"&"R#(.....0"""6/1DtUD%u %G0G0G0G0G0T0$0$0$0$0$r