a �DOg���@stddlZddlZddlZddlZddlZddlZddlZddlZddlZddlm Z gd�Z Gdd�de �Z Gdd�d�Z e �ZGdd �d �Ze�Ze�i�ZGd d �d �Zed �Zed �Zed�ZdZdZdZe�d�ZGdd�d�ZGdd�d�ZGdd�d�Zeedddddd�dd�Zdd�Z dd �Z!dded!�d"d#�Z"d$d%�Z#d&d'�Z$d(d)�Z%d*d+�Z&d,d-�Z'd.d/�Z(d0d1�Z)d2d3�Z*d4d5�Z+d6d7�Z,d8d9�Z-d:d;�Z.dd?�Z0d@dA�Z1dBdC�Z2dddde0de1de1e2e1e2e1e2e1e2dD�Z3dEdF�Z4daddddGdGdGdH�dIdJ�Z5dKdL�Z6dMdN�Z7dOdP�Z8e9dQ�dRdS�Z:dTdU�Z;ed[dddddGdGdGd\�d]d^�Z?d_d`�Z@dS)b�N)� GenericAlias) � dataclass�field�Field�FrozenInstanceError�InitVar�MISSING�fields�asdict�astuple�make_dataclass�replace� is_dataclassc@s eZdZdS)rN��__name__� __module__� __qualname__�rr�#/usr/lib64/python3.9/dataclasses.pyr��rc@seZdZdd�ZdS)�_HAS_DEFAULT_FACTORY_CLASScCsdS)Nz r��selfrrr�__repr__�sz#_HAS_DEFAULT_FACTORY_CLASS.__repr__N)rrrrrrrrr�src@s eZdZdS)� _MISSING_TYPENrrrrrr�src@seZdZdd�Zdd�ZdS)� _FIELD_BASEcCs ||_dS�N��name�rrrrr�__init__�sz_FIELD_BASE.__init__cCs|jSrrrrrrr�sz_FIELD_BASE.__repr__N)rrrr rrrrrr�sr�_FIELD�_FIELD_CLASSVAR�_FIELD_INITVARZ__dataclass_fields__Z__dataclass_params__Z __post_init__z^(?:\s*(\w+)\s*\.)?\s*(\w+)c@s(eZdZdZdd�Zdd�Zdd�ZdS) r��typecCs ||_dSrr$)rr%rrrr �szInitVar.__init__cCs8t|jt�r"t|jt�s"|jj}n t|j�}d|�d�S)Nzdataclasses.InitVar[�])� isinstancer%rr�repr)r� type_namerrrr�s  zInitVar.__repr__cCst|�Sr)r)�clsr%rrr�__class_getitem__�szInitVar.__class_getitem__N)rrr� __slots__r rr+rrrrr�src@s0eZdZdZdd�Zdd�Zdd�Zee�Z dS) r) rr%�default�default_factoryr(�hash�init�compare�metadata� _field_typecCsRd|_d|_||_||_||_||_||_||_|dur#sr>T�r-r.r0r(r/r1r2cCs,|tur|turtd��t|||||||�S)Nz/cannot specify both default and default_factory)r� ValueErrorrrDrrrrBs �rcs(|sdSdd��fdd�|D���d�S)N�()�(�,csg|]}��d|j���qS)�.r��.0�f��obj_namerr� arz_tuple_str..�,))�join)rNr rrMr� _tuple_strXsrRcs"t��t�����fdd��}|S)Nc sNt|�t��f}|�vrdS��|�z�|�}W��|�n ��|�0|S)Nz...)�id�_thread� get_ident�add�discard)r�key�result�� repr_running� user_functionrr�wrapperks  z _recursive_repr..wrapper)�set� functools�wraps)r\r]rrZr�_recursive_reprfs ra)�globals�locals� return_typec Cs�|dur i}d|vrt|d<d}|tur4||d<d}d�|�}d�dd�|D��}d |�d |�d |�d |��}d �|���}d|�d|�d|��}i} t||| �| dfi|��S)NZBUILTINS�Z _return_typez->_return_typerH� css|]}d|��VqdS)z Nr)rK�brrr� �rz_create_fn..z def rGr8z: �, zdef __create_fn__(z): z return Z __create_fn__)�builtinsrrQ�keys�exec) r�args�bodyrbrcrdZreturn_annotationZtxtZ local_vars�nsrrr� _create_fnys   rpcCs0|rd|�d|�d|�d�S|�d|�d|��S)NzBUILTINS.object.__setattr__(rHr8rI�=r)rCr�value� self_namerrr� _field_assign�srtcCs�d|j��}|jturV|jr@|j||<|�d|j�d|j��}q�|j||<|�d�}n8|jr�|jturn|j}q�|jtur�|j||<|j}ndS|jtur�dSt||j||�S)NZ_dflt_z() if z is _HAS_DEFAULT_FACTORY else rF)rr.rr0r-r3r#rt)rLrCrbrsZ default_namerrrrr� _field_init�s*   ��      rucCsV|jtur|jturd}n&|jtur2d|j��}n|jtur@d}|j�d|j�|��S)Nrez=_dflt_z=_HAS_DEFAULT_FACTORYz:_type_)r-rr.r)rLr-rrr� _init_param�s  rvc Cs�d}|D]:}|jr|jtur&|jtus,d}q|rtd|j�d���qdd�|D�}|�ttd��g}|D] }t||||�} | rj|� | �qj|r�d� d d �|D��} |� |�d t �d | �d ��|s�dg}t d|gdd�|D�|||dd�S)NFTznon-default argument z follows default argumentcSsi|]}d|j��|j�qS)Z_type_)rr%rJrrr� �rz_init_fn..)r�_HAS_DEFAULT_FACTORYrHcss|]}|jtur|jVqdSr)r3r#rrJrrrrh s �z_init_fn..rIrGr8�passr cSsg|]}|jrt|��qSr)r0rvrJrrrrOrz_init_fn..)rcrbrd) r0r-rr.� TypeErrorr�updaterxru�appendrQ�_POST_INIT_NAMErp) r rC� has_post_initrsrbZ seen_defaultrLrcZ body_lines�lineZ params_strrrr�_init_fn�s:� �r�cCs2tdddd�dd�|D��dg|d�}t|�S) Nrrz(return self.__class__.__qualname__ + f"(ricSs g|]}|j�d|j�d��qS)z={self.z!r}rrJrrrrOs�z_repr_fn..z)"�rb)rprQra)r rb�fnrrr�_repr_fns ����r�cCsp|td�}|r,dd�dd�|D��d}nd}tdd d |�d �d d f||d�tddd |�d �ddf||d�fS)N)r*rrGrHcss|]}t|j�VqdSr)r(rrJrrrrh*rz'_frozen_get_del_attr..rPrF� __setattr__)rrrrz if type(self) is cls or name in �:z> raise FrozenInstanceError(f"cannot assign to field {name!r}")z)super(cls, self).__setattr__(name, value))rcrb� __delattr__rz; raise FrozenInstanceError(f"cannot delete field {name!r}")z"super(cls, self).__delattr__(name))rrQrp)r*r rbrcZ fields_strrrr�_frozen_get_del_attr&s2� �� ���r�cCs$t|ddd|�|�|��dg|d�S)N)r�otherz%if other.__class__ is self.__class__:z return zreturn NotImplementedr�)rp)r�op� self_tuple� other_tuplerbrrr�_cmp_fn?s��r�cCs$td|�}tddd|�d�g|d�S)Nr�__hash__rz return hash(r8r�)rRrp)r rbr�rrr�_hash_fnMs   �r�cCs$||jup"t|�|juo"|j|juSr)�ClassVarr%� _GenericAlias� __origin__)�a_type�typingrrr� _is_classvarUs  �r�cCs||jupt|�|juSr)rr%)r�� dataclassesrrr� _is_initvar]s  �r�c Cs�t�|�}|r�d}|�d�}|s2tj�|j�j}n2tj�|j�}|rd|j�|�|urdtj�|j�j}|r�||�|�d��|�r�dSdS)N��TF)�_MODULE_IDENTIFIER_RE�match�group�sys�modules�getr�__dict__) � annotationr*Za_moduler�Zis_type_predicater�ro� module_name�modulerrr�_is_typeds)  r�cCs8t||t�}t|t�r|}nt|tj�r,t}t|d�}||_||_t |_ t j � d�}|r�t||�s�t|jt�r�t|j|||jt�r�t|_ |j t ur�t j t}t||�s�t|jt�r�t|j|||jt�r�t|_ |j ttfvr�|jtur�td|j�d���|j t u�r4t|jtttf��r4tdt|j��d|j�d���|S)N)r-r��field z cannot have a default factoryzmutable default z for field z$ is not allowed: use default_factory)r:rr'rr5�MemberDescriptorTyperrr%r!r3r�r�r�r��strr�r�r"rr�rr#r.rzr-�list�dictr^rE)r*Za_namer�r-rLr�r�rrr� _get_field�sJ       ���    ���  � r�cCs||jvrdSt|||�dS)NTF)r��setattr)r*rrrrrr�_set_new_attribute�s  r�cCsdSrr�r*r rbrrr�_hash_set_none�sr�cCsdd�|D�}t||�S)NcSs(g|] }|jdur|jrn|jr|�qSr)r/r1rJrrrrOrz_hash_add..)r�)r*r rb�fldsrrr� _hash_addsr�cCstd|j����dS)Nz-Cannot overwrite attribute __hash__ in class )rzrr�rrr�_hash_exceptions�r�))FFFF)FFFT)FFTF)FFTT)FTFF)FTFT)FTTF)FTTT)TFFF)TFFT)TFTF)TFTT)TTFF)TTFT)TTTF)TTTTc s�i}�jtjvr tj�jj}ni}t�tt||||||��d} d} �jddd�D]D} t| t d�} | durVd} | � �D]} | || j <qzt| t�j rVd} qV�j� di�}�fdd�|��D�}|D]L} | || j <tt�| j d�t�r�| jtu�rt�| j �q�t�| j | j�qĈj��D].\}}t|t��r||v�rt|�d����q| �rz| �rf|�sftd ��| �sz|�rztd ��t�t |��j� d t�}|tu�p�|du�o�d �jv }|�r�|�s�td ��|�rt�t�}dd�|� �D�}t�dt|||d|v�rdnd|��dd�|� �D�}|�rHdd�|D�}t�dt||��|�r�dd�|D�}td|�}td|�}t�d td d|||d��|�r�dd�|D�}td|�}td|�}dD]>\}}t�|t|||||d���r�td|�d�j�d����q�|�r8t�||�D].}t�|j|��rtd|j�d�j�����qtt |�t |�t |�|f}|�rh|�||��_!t�d��s��jt"t#�$����%dd ��_&�S)!NF�����rT�__annotations__csg|]\}}t�||��qSr)r�)rKrr%�r*rrrO_s�z"_process_class..z& is a field but has no type annotationz5cannot inherit non-frozen dataclass from a frozen onez5cannot inherit frozen dataclass from a non-frozen oner��__eq__z eq must be true if order is truecSsg|]}|jttfvr|�qSr)r3r!r#rJrrrrO�s�r rZ__dataclass_self__cSsg|]}|jtur|�qSr�r3r!rJrrrrO�rcSsg|]}|jr|�qSr)r(rJrrrrO�rrcSsg|]}|jr|�qSr�r1rJrrrrO�rr�z==r�cSsg|]}|jr|�qSrr�rJrrrrO�r))�__lt__�<)�__le__z<=)�__gt__�>)�__ge__z>=zCannot overwrite attribute z in class z). Consider using functools.total_ordering�__doc__z -> Nonere)'rr�r�r�r��_PARAMSr>�__mro__r:�_FIELDS�valuesrrCr��itemsr'rr-r�delattrrzrE�hasattrr}r�r�r�rRr�rr�� _hash_action�boolr�r��inspectZ signaturer r�)r*r0r(r@rArBrCr rbZany_frozen_baseZhas_dataclass_basesrgZ base_fieldsrLZcls_annotationsZ cls_fieldsrrrZ class_hashZhas_explicit_hashr~r�Z field_listr�r�r�r�Z hash_actionrr�r�_process_class)s� �     �      �  ��  ��    �� � � � �r�Fr?cs*������fdd�}|dur"|S||�S)Ncst|�������Sr)r�r��r@rCr0rAr(rBrr�wrap�szdataclass..wrapr)r*r0r(r@rArBrCr�rr�rr�srcCs@zt|t�}Wnty(td��Yn0tdd�|��D��S)Nz0must be called with a dataclass type or instancecss|]}|jtur|VqdSrr�rJrrrrhrzfields..)r:r��AttributeErrorrz�tupler�)Zclass_or_instancer rrrr s  r cCstt|�t�Sr)r�r%r�)�objrrr�_is_dataclass_instancesr�cCs*t|t�rt|t�s|nt|�}t|t�Sr)r'r%rr�r�)r�r*rrrrs r�� dict_factorycCst|�std��t||�S)Nz0asdict() should be called on dataclass instances)r�rz� _asdict_inner)r�r�rrrr sr cs�t|�rDg}t|�D]&}tt||j���}|�|j|f�q�|�St|t�rrt|d�rrt |��fdd�|D��St|t tf�r�t |��fdd�|D��St|t �r�t |��fdd�|� �D��St �|�SdS)N�_fieldscsg|]}t|���qSr�r��rK�vr�rrrOQrz!_asdict_inner..c3s|]}t|��VqdSrr�r�r�rrrhVrz _asdict_inner..c3s&|]\}}t|��t|��fVqdSrr��rK�kr�r�rrrhXs��)r�r r�r:rr|r'r�r�r%r�r�r��copy�deepcopy)r�r�rYrLrrrr�rr�6s  �r��� tuple_factorycCst|�std��t||�S)Nz1astuple() should be called on dataclass instances)r�rz�_astuple_inner)r�r�rrrr _sr cs�t|�r>g}t|�D] }tt||j���}|�|�q�|�St|t�rlt|d�rlt |��fdd�|D��St|t tf�r�t |��fdd�|D��St|t �r�t |��fdd�|� �D��St �|�SdS)Nr�csg|]}t|���qSr�r�r�r�rrrO�rz"_astuple_inner..c3s|]}t|��VqdSrr�r�r�rrrh�rz!_astuple_inner..c3s&|]\}}t|��t|��fVqdSrr�r�r�rrrh�s�)r�r r�r:rr|r'r�r�r%r�r�r�r�r�)r�r�rYrLrrrr�rr�ws   �r�r)�bases� namespacer0r(r@rArBrCc s�duri�n����t�} i} |D]�} t| t�r<| } d}nDt| �dkrR| \} }n.t| �dkrr| \} }}|�| <ntd| ����t| t�r�| ��s�td| ����t�| �r�td| ����| | vr�td| ����| � | �|| | <q$| �d<t � ||i�fd d ��}t ||||||| d �S) Nz typing.Anyr��zInvalid field: z'Field names must be valid identifiers: z"Field names must not be keywords: zField name duplicated: r�cs |���Sr)r{)ro�r�rr��rz make_dataclass..r?) r�r^r'r��lenrz� isidentifier�keyword� iskeywordrVr5� new_classr)�cls_namer r�r�r0r(r@rArBrC�seenZanns�itemr�tp�specr*rr�rr �s8          �r cKs�t|�std��t|t���D]v}|jtur.q|jsR|j|vrt d|j�d���q|j|vr|jt ur�|j t ur�t d|j�d���t||j�||j<q|j fi|��S)Nz1replace() should be called on dataclass instancesr�zC is declared with init=False, it cannot be specified with replace()zInitVar z! must be specified with replace())r�rzr:r�r�r3r"r0rrEr#r-r� __class__)r�ZchangesrLrrrr �s   r )N)A�rer�r�r5r�r�rjr_rTr�__all__r�rrrxrrr6r4rr!r"r#r�r�r}�compiler�rrr>rrRrarprtrurvr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr r�rr�r r�r�r r�r r rrrr�s�   <� �  62 ;R�> � )� B