
    Rh9                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dlm
Z
mZ g dZ G d de      Z G d d      Z e       Z G d d	      Z e       Z G d
 d      Z e       Z ej*                  i       Z G d d      Z ed      Z ed      Z ed      ZdZdZdZ e j<                  d      Z e ejB                  e"e#e$e%e&e'ejP                  ejR                  ejT                  ejV                  ej                  e,e-e.h      Z/d Z0 G d d      Z1 G d d      Z2 G d d      Z3eedddddeddZ4d Z5d  Z6dded!d"Z7d# Z8d$ Z9d% Z:d& Z;d' Z<d( Z=d) Z>d* Z?d+ Z@d, ZAd- ZBd. ZCd/ ZDd0 ZEd1 ZFd2 ZGd3 ZHd4 ZIi d5dd6dd7dd8dd9eGd:dd;eHd<dd=eHd>eId?eHd@eIdAeHdBeIdCeHdDeIZJdE ZKdF ZLdG ZMdH ZNdI ZOdZddddJdJdJddJdJdJdK
dLZPdM ZQdN ZRdO ZSeTdPdQZUdR ZVeWdSdTZXdU ZYdVdddddJdJdJddJdJdJddWdXZZdY Z[y)[    N)FunctionTypeGenericAlias)	dataclassfieldFieldFrozenInstanceErrorInitVarKW_ONLYMISSINGfieldsasdictastuplemake_dataclassreplaceis_dataclassc                       e Zd Zy)r   N__name__
__module____qualname__     "/usr/lib/python3.12/dataclasses.pyr   r      s    r   r   c                       e Zd Zd Zy)_HAS_DEFAULT_FACTORY_CLASSc                      y)Nz	<factory>r   selfs    r   __repr__z#_HAS_DEFAULT_FACTORY_CLASS.__repr__   s    r   N)r   r   r   r   r   r   r   r   r      s    r   r   c                       e Zd Zy)_MISSING_TYPENr   r   r   r   r!   r!          r   r!   c                       e Zd Zy)_KW_ONLY_TYPENr   r   r   r   r$   r$      r"   r   r$   c                       e Zd Zd Zd Zy)_FIELD_BASEc                     || _         y Nnamer   r*   s     r   __init__z_FIELD_BASE.__init__   	    	r   c                     | j                   S r(   r)   r   s    r   r   z_FIELD_BASE.__repr__   s    yyr   N)r   r   r   r,   r   r   r   r   r&   r&      s    r   r&   _FIELD_FIELD_CLASSVAR_FIELD_INITVAR__dataclass_fields____dataclass_params____post_init__z^(?:\s*(\w+)\s*\.)?\s*(\w+)c                 Z     t               t        j                          fd       }|S )Nc                     t        |       t        j                         f}|v ryj                  |       	  |       }j	                  |       |S # j	                  |       w xY w)Nz...)id_thread	get_identadddiscard)r   keyresultrepr_runninguser_functions      r   wrapperz _recursive_repr.<locals>.wrapper   sg    h))++,	&"4(F  %   %s   A A&)set	functoolswraps)r?   r@   r>   s   ` @r   _recursive_reprrD      s.     5L__]#	 $	 Nr   c                   "    e Zd ZdZd Zd Zd Zy)r	   typec                     || _         y r(   rF   )r   rG   s     r   r,   zInitVar.__init__  r-   r   c                     t        | j                  t              r| j                  j                  }nt        | j                        }d| dS )Nzdataclasses.InitVar[])
isinstancerG   r   repr)r   	type_names     r   r   zInitVar.__repr__  s=    dii&		**I TYYI%i[22r   c                     t        |      S r(   )r	   )clsrG   s     r   __class_getitem__zInitVar.__class_getitem__  s    t}r   N)r   r   r   	__slots__r,   r   rP   r   r   r   r	   r	     s    I3r   r	   c                   <    e Zd ZdZd Zed        Zd Z ee	      Z
y)r   )r*   rG   defaultdefault_factoryrL   hashinitcomparemetadatakw_only_field_typec	                     d | _         d | _        || _        || _        || _        || _        || _        || _        |t        nt        j                  |      | _        || _        d | _        y r(   )r*   rG   rS   rT   rV   rL   rU   rW   _EMPTY_METADATAtypesMappingProxyTyperX   rY   rZ   )	r   rS   rT   rV   rL   rU   rW   rX   rY   s	            r   r,   zField.__init__5  sl    		.			$, )//9 	 r   c                 &   d| j                   d| j                  d| j                  d| j                  d| j                  d| j
                  d| j                  d| j                  d	| j                  d
| j                  d| j                   dS )NzField(name=z,type=z	,default=z,default_factory=z,init=,repr=z,hash=z	,compare=z
,metadata=	,kw_only=z,_field_type=))r*   rG   rS   rT   rV   rL   rU   rW   rX   rY   rZ   r   s    r   r   zField.__repr__E  s    		} %		} %<<* +##'#7#7": ;		} %		} %		} %<<* + MM, -<<* +#//0 	r   c                 r    t        t        | j                        dd       }|r || j                  ||       y y )N__set_name__)getattrrG   rS   )r   ownerr*   funcs       r   rd   zField.__set_name__]  s3    tDLL)>4@ ud+ r   N)r   r   r   rQ   r,   rD   r   rd   classmethodr   rP   r   r   r   r   r   '  s4    I    ., $L1r   r   c                       e Zd ZdZd Zd Zy)_DataclassParams
rV   rL   eqorderunsafe_hashfrozen
match_argsrY   slotsweakref_slotc                     || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        y r(   rk   )r   rV   rL   rl   rm   rn   ro   rp   rY   rq   rr   s              r   r,   z_DataclassParams.__init__t  sL     		
&$
(r   c                    d| j                   d| j                  d| j                  d| j                  d| j                  d| j
                  d| j                  d| j                  d	| j                  d
| j                  dS )Nz_DataclassParams(init=r`   z,eq=z,order=z,unsafe_hash=z,frozen=z,match_args=ra   z,slots=z,weakref_slot=rb   rk   r   s    r   r   z_DataclassParams.__repr__  s    		} %		} %gg[ ! '#//2 3++ )"oo0 1<<* + '  $ 1 14 	r   N)r   r   r   rQ   r,   r   r   r   r   rj   rj   g  s    
I)r   rj   TrS   rT   rV   rL   rU   rW   rX   rY   c           
      \    | t         ur|t         urt        d      t        | |||||||      S )a  Return 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   
ValueErrorr   ru   s           r   r   r     s=    $ g/"@JKK/4tW7$ $r   c                 J    t        d | D              t        d | D              fS )Nc              3   T   K   | ]   }|j                   s|j                  r| " y wr(   rV   rY   .0fs     r   	<genexpr>z(_fields_in_init_order.<locals>.<genexpr>  s     @qvvaii!@   (((c              3   T   K   | ]   }|j                   s|j                  s| " y wr(   rz   r{   s     r   r~   z(_fields_in_init_order.<locals>.<genexpr>  s     <qvv!))!<r   )tuple)r   s    r   _fields_in_init_orderr     s*     @V@@<V<< r   c           	      v    |syddj                  |D cg c]  }|  d|j                    c}       dS c c}w )N()(,.z,))joinr*   )obj_namer   r}   s      r   
_tuple_strr     s@     sxx@AH:Qqvvh/@AB"EE@s   6
)globalslocalsreturn_typec                "   |i }d}|t         ur||d<   d}dj                  |      }dj                  d |D              }d|  d| d	| d
| }dj                  |j                               }d| d| d|  }i }	t        |||	        |	d   di |S )N __dataclass_return_type__z->__dataclass_return_type__r   
c              3   &   K   | ]	  }d |   yw)z  Nr   )r|   bs     r   r~   z_create_fn.<locals>.<genexpr>  s     ,!r!X,s   z def r   rb   z:
, zdef __create_fn__(z):
z	
 return __create_fn__r   )r   r   keysexec)
r*   argsbodyr   r   r   return_annotationtxt
local_varsnss
             r   
_create_fnr     s    
 ~'!.9*+988D>D99,t,,D $qa 12#dV
<C 6;;=)Jzl$se:dV
DC	Bgr2o(((r   c                 2    | rd| d|d| dS | d| d| S )Nz*__dataclass_builtins_object__.__setattr__(r   rb   r   =r   )ro   r*   value	self_names       r   _field_assignr     s<     ;I;axqQVPWWXYY[$q((r   c                 :   d| j                    d}| j                  t        urO| j                  r.| j                  ||<   | d| j                    d| j                    }n| j                  ||<   | d}n| j                  rM| j                  t        u r| j                   }nU| j                  t        urC| j                  ||<   | j                   }n'|r$| j                  t        ur| j                  ||<   |}ny | j
                  t        u ry t        || j                   |      S )N__dataclass_dflt___z() if z+ is __dataclass_HAS_DEFAULT_FACTORY__ else r   )r*   rT   r   rV   rS   rZ   r1   r   )r}   ro   r   r   rq   default_namer   s          r   _field_initr     s    'qvvhb1L'66 %&$5$5GL!$~ &66( #VVH&E$ %&$5$5GL!#nB'E 66yyG#')()		% '1()		%$
 
 	}}& 	::r   c                     | j                   t        u r| j                  t        u rd}n7| j                   t        urd| j                   d}n| j                  t        urd}| j                   d| j                   d S )Nr   z=__dataclass_dflt_r   z"=__dataclass_HAS_DEFAULT_FACTORY__z:__dataclass_type_)rS   r   rT   r*   )r}   rS   s     r   _init_paramr   %  sw    
 	yyG 1 1W < 	
'	! 'qvvhb1	
		'	)6ffX'xr';;r   c                    d}|D ]Q  }	|	j                   s|	j                  t        u r|	j                  t        u sd}7|s:t	        d|	j
                  d       | D 	ci c]  }	d|	j
                   d|	j                   }
}	|
j                  t        t        d       g }| D ]%  }	t        |	||
||      }|s|j                  |       ' |r6dj                  d	 | D              }|j                  | d
t         d| d       |sdg}|D 	cg c]  }	t        |	       }}	|r"|dgz  }||D 	cg c]  }	t        |	       c}	z  }t        d|g|z   ||
|d       S c c}	w c c}	w c c}	w )NFTznon-default argument z follows default argument__dataclass_type_r   )!__dataclass_HAS_DEFAULT_FACTORY____dataclass_builtins_object__r   c              3   X   K   | ]"  }|j                   t        u r|j                   $ y wr(   )rZ   r1   r*   r{   s     r   r~   z_init_fn.<locals>.<genexpr>\  s)      B!".!@  ff Bs   (*r   r   rb   pass*r,   )r   r   r   )rV   rS   r   rT   	TypeErrorr*   rG   update_HAS_DEFAULT_FACTORYobjectr   appendr   _POST_INIT_NAMEr   r   )r   
std_fieldskw_only_fieldsro   has_post_initr   r   rq   seen_defaultr}   r   
body_linesline
params_str_init_paramss                  r   _init_fnr   8  s    L <66II(Q->->'-I#"7z B; !; < << ?EE!!&&,aff4EFE
MM-A)/ 
 J $1ffi? d#$ XX Bf B B
YKq(9:,aHI X
,67qKN7L7 	@AQ@@j kL0 #%"&( (? F0 8 As   "E
E+E!c                     t        ddddj                  | D cg c]  }|j                   d|j                   d  c}      z   dz   g|      }t        |      S c c}w )	Nr   r   z(return self.__class__.__qualname__ + f"(r   z={self.z!r}z)"r   )r   r   r*   rD   )r   r   r}   fns       r   _repr_fnr   s  sv    	J?YY)/ 1$% $%66((166($ ?  1 22   %
&B 2	 1s   #Ac                     | t         d}d}|r!|ddj                  d |D              z   dz   z  }t        ddd	| d
ddf||      t        ddd	| d
ddf||      fS )N)rO   r   ztype(self) is clsz or name in {r   c              3   F   K   | ]  }t        |j                          y wr(   )rL   r*   r{   s     r   r~   z'_frozen_get_del_attr.<locals>.<genexpr>  s     0N!aff0Ns   !}__setattr__)r   r*   r   zif :z> raise FrozenInstanceError(f"cannot assign to field {name!r}")z)super(cls, self).__setattr__(name, value))r   r   __delattr__r+   z; raise FrozenInstanceError(f"cannot delete field {name!r}")z"super(cls, self).__delattr__(name))r   r   r   )rO   r   r   r   	conditions        r   _frozen_get_del_attrr   ~  s    %8:F#I_tyy0Nv0N'NNQTTT	}/YKq)XBE %&( }&YKq)U;> %&( r   c           	      4    t        | ddd| | | dg|      S )N)r   otherz%if other.__class__ is self.__class__:z return zreturn NotImplementedr   )r   )r*   op
self_tupleother_tupler   s        r   _cmp_fnr     s8     d'?!*bT+?/1 &' 'r   c                 B    t        d|       }t        ddd| dg|      S )Nr   __hash__r   zreturn hash(rb   r   )r   r   )r   r   r   s      r   _hash_fnr     s2    FF+Jj%j\34%' 'r   c                     | |j                   u xs1 t        |       |j                  u xr | j                  |j                   u S r(   )ClassVarrG   _GenericAlias
__origin__)a_typetypings     r   _is_classvarr     sC     foo% :V 4 44 9%%8;r   c                 P    | |j                   u xs t        |       |j                   u S r(   )r	   rG   r   dataclassess     r   _is_initvarr     s.     k))) 3F|{2224r   c                     | |j                   u S r(   )r
   r   s     r   _is_kw_onlyr     s    [((((r   c                    t         j                  |       }|rd }|j                  d      }|s4t        j                  j                  |j                        j                  }n{t        j                  j                  |j                        }|rP|j                  j                  |      |u r3t        j                  j                  |j                        j                  }|r( ||j                  |j                  d            |      ryy)N      TF)_MODULE_IDENTIFIER_REmatchgroupsysmodulesgetr   __dict__)	
annotationrO   a_moduler   is_type_predicater   r   module_namemodules	            r   _is_typer     s    R "''
3Ekk!n 099B [[__S^^4F&//--k:hF[[__V%6%67@@#BFF5;;q>$:HEr   c                    t        | |t              }t        |t              r|}n,t        |t        j
                        rt        }t        |      }||_        ||_        t        |_
        t        j                  j                  d      }|rXt        ||      sAt        |j                  t              r2t!        |j                  | ||j"                  t              rt$        |_
        |j                  t        u rot        j                  t&           }t)        ||      sAt        |j                  t              r2t!        |j                  | ||j*                  t(              rt,        |_
        |j                  t$        t,        fv r+|j.                  t        urt1        d|j                   d      |j                  t        t,        fv r|j2                  t        u rG||_        n?|j                  t$        u sJ |j2                  t        urt1        d|j                   d      |j                  t        u rO|j4                  j6                  j8                  /t;        dt        |j4                         d|j                   d      |S )	N)rS   r   field z cannot have a default factoryz$ is a ClassVar but specifies kw_onlyzmutable default z for field z$ is not allowed: use default_factory)re   r   rK   r   r]   MemberDescriptorTyper   r*   rG   r/   rZ   r   r   r   r   strr   r   r0   r   r   r	   r1   rT   r   rY   rS   	__class__r   rw   )rO   a_namer   default_kw_onlyrS   r}   r   r   s           r   
_get_fieldr     s    c67+G'5!gu99:G'" AFAF
 AM  [[__X&F(1663'QVVS&&//)++AM 	}} kk(+,1663'QVVS+{7J7J(**AM 	}}.99G+fQVVH -. . / / 	}}00 99'AI }}///99G#fQVVH -& & ' ' 	}}199#6#6#?#?#G+DO+<KFF8#GI J 	J Hr   c                 f    t        |t              r | j                   d|j                   |_        |S )Nr   )rK   r   r   r   )rO   r   s     r   _set_qualnamer   Y  s2     %& # 0 015>>2BCLr   c                 T    || j                   v ryt        | |       t        | ||       y)NTF)r   r   setattr)rO   r*   r   s      r   _set_new_attributer   `  s,     s||#uCur   c                      y r(   r   rO   r   r   s      r   _hash_set_noner  o  s    r   c                     |D cg c]+  }|j                   |j                  sn|j                   s*|- }}t        | t        ||            S c c}w r(   )rU   rW   r   r   )rO   r   r   r}   fldss        r   	_hash_addr  r  sC    K!qvv~!))166AKDKhtW566 Ls   AAAc                 2    t        d| j                         )Nz-Cannot overwrite attribute __hash__ in class )r   r   r  s      r   _hash_exceptionr  v  s"    
   #~/ 0 0r   )FFFF)FFFT)FFTF)FFTT)FTFF)FTFT)FTTF)FTTT)TFFF)TFFT)TFTF)TFTT)TTFF)TTFT)TTTF)TTTTc                    i }| j                   t        j                  v r(t        j                  | j                      j                  }ni }t	        | t
        t        |||||||||	|

             d}d}| j                  ddd   D ]Y  }t        |t        d       }|d}|j                         D ]  }|||j                  <    t        |t
              j                  sXd}[ t        j                  |       }g }d}t        j                  t           }|j!                         D ]p  \  }}t#        ||      s-t%        |t&              r2t)        || ||j*                  t"              r|rt-        |d      d}d}T|j/                  t1        | |||             r |D ]  }|||j                  <   t%        t        | |j                  d       t2              s8|j4                  t6        u rt9        | |j                         at	        | |j                  |j4                          | j                  j!                         D ](  \  }}t%        |t2              s||vst-        |d       |r|r|st-        d      |s|rt-        d      t	        | t        |       | j                  j;                  d	t6              }|t6        u xs |d u xr d
| j                  v  }|r|st=        d      |j                         D cg c]  }|j>                  t@        tB        fv r| }}tE        |      \  }}|r3tG        | tH              }tK        | dtM        |||||d|v rdnd||	             |j                         D cg c]  }|j>                  t@        u s| }}|r3|D cg c]  }|jN                  s| } }tK        | dtQ        | |             |rO|D cg c]  }|jR                  s| } }tU        d|       }!tU        d|       }"tK        | d
tW        d
d|!|"|             |ru|D cg c]  }|jR                  s| } }tU        d|       }!tU        d|       }"dD ]<  \  }}#tK        | |tW        ||#|!|"|            s"t-        d| d| j                   d       |rNtY        | ||      D ]>  }$tK        | |$j                  |$      st-        d|$j                   d| j                          tZ        t]        |      t]        |      t]        |      |f   }%|%r |%| ||      | _/        t        | d      sC	 t'        t        j`                  |             jc                  dd      }&| j                  |&z   | _2        |rtK        | dtg        d |D                     |
r|	st-        d      |	rti        | ||
      } tk        jl                  |        | S c c}w c c}w c c}w c c}w c c}w # t,        t<        f$ r d}&Y w xY w)NFr   Tz3 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 oner   __eq__z eq must be true if order is truer,   r   __dataclass_self__r   r   z==r   ))__lt__<)__le__z<=)__gt__>)__ge__z>=zCannot overwrite attribute z
 in class z). Consider using functools.total_ordering__doc__z -> Noner   __match_args__c              3   4   K   | ]  }|j                     y wr(   r)   r{   s     r   r~   z!_process_class.<locals>.<genexpr>v  s      AA A   z'weakref_slot is True but slots is False)7r   r   r   r   r   _PARAMSrj   __mro__re   _FIELDSvaluesr*   ro   inspectget_annotationsr   itemsr   rK   r   r   r
   r   r   r   r   rS   r   delattrr   rw   rZ   r/   r1   r   hasattrr   r   r   rL   r   rW   r   r   r   _hash_actionboolr   	signaturer   r  r   
_add_slotsabcupdate_abstractmethods)'rO   rV   rL   rl   rm   rn   ro   rp   rY   rq   rr   r   r   any_frozen_basehas_dataclass_basesr   base_fieldsr}   cls_annotations
cls_fieldsKW_ONLY_seenr   r*   rG   r   
class_hashhas_explicit_hashall_init_fieldsstd_init_fieldskw_only_init_fieldsr   
field_listr  r   r   r   r   hash_actiontext_sigs'                                          r   _process_classr3    s2    F
~~$++cnn-66 C*4r5+6+5w+0,@ A O[[Ab! 	' a$/""& '') #!"qvv#q'"))"&	'( --c2O
 JL++h'K%++- D
dk*4%T3[5H5H(* 4( += != > >LG jdD'BCD"  0qvv gc16640%8yyG# QVV$QVVQYY/#0( ||))+ OeeU#DO,Cth&LMNNO
 6 ) * * 6 - . .
 C&! !!*g6J'72 O(D0MX5MP
 R;<<
 #)--/ EQ--FN+CC  EO E 2/B__53
#O$3$7$*$1 =Cf<L$817$+$)	" $]]_H0G!HJH%0a003
HT7,CD	 &3a33-
 $/3"8T#-{+24	5
 %3a33-
 $/ 
	<HD"
 "#t")$J29#;<  "=dV D,,/LL> :;!; < <
	< &sJ@ 	<B!#r{{B7"=bkk] K,,/LL>!; < <	< tK0#Bx#F|0 1 2K  #3
G<3	"	 7,,S12:::rJH ||h.3 0  A AA	C EABBfl3s#JGE4 I 1 4 4J :& 	H	sH   -!V,%V1=V1	V6V6>V;V;W !W .W WWc                 f    t        |       D cg c]  }t        | |j                         c}S c c}w r(   )r   re   r*   )r   r}   s     r   _dataclass_getstater5    s%    +1$<8aGD!&&!888s   .c                     t        t        |       |      D ]&  \  }}t        j                  | |j                  |       ( y r(   )zipr   r   r   r*   )r   stater   r   s       r   _dataclass_setstater9    s6    F4L%0 4u4U34r   c              #      K   | j                   j                  d      x dE d {    y xt        dx	\  } | y  }t        |d      s|E d {    y 	 t	        d| j
                   d      7 K7 !w)NrQ   )r   __weakref__r   __next__z
Slots of 'z' cannot be determined)r   r   r   r  r   r   )rO   slotiterables      r   
_get_slotsr?    su     
,,

;
' 222SYJ  WXz:j6LMNN 3  s!   #A5A1+A5A3 A53A5c           
         d| j                   v rt        | j                   d      t        | j                         }t	        d t        |       D              }t        t        j                  j                  t        t        | j                  dd                   }t	        t        j                  |j                  t        j                  ||rdnd                  |d<   |D ]  }|j                  |d         |j                  dd        |j                  d	d        t!        | d
d       } t#        |       | j                  | j$                  |      } ||| _        |rd|vrt(        | _        d|vrt,        | _        | S )NrQ   z already specifies __slots__c              3   4   K   | ]  }|j                     y wr(   r)   r{   s     r   r~   z_add_slots.<locals>.<genexpr>  s     414r  r   r	  )r;  r   r   r;  r   __getstate____setstate__)r   r   r   dictr   r   rA   	itertoolschainfrom_iterablemapr?  r  filterfalse__contains__popre   rG   	__bases__r   r5  rB  r9  rC  )rO   	is_frozenrr   cls_dictfield_namesinherited_slots
field_namequalnames           r   r"  r"    s\   
 cll"3<<.(DEFF CLL!H4s44K%%c*ckk!B6G&HIO
 "((OO -2	
	H[ " '
 	Z&' LLT" LL% sND1H
$s)CLL#--
:C#)2C)2CJr   Frk   c      
   
      J   	
 	
f
d}| |S  ||       S )a  Add 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                 .   
 t        | 	
      S r(   )r3  )rO   rl   ro   rV   rY   rp   rm   rL   rq   rn   rr   s    r   wrapzdataclass.<locals>.wrap  s(    c4r5+$j'5*, 	,r   r   )rO   rV   rL   rl   rm   rn   ro   rp   rY   rq   rr   rU  s    `````````` r   r   r     s&    ", , { 9r   c                     	 t        | t              }t	        d |j                         D              S # t        $ r t        d      dw xY w)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 instanceNc              3   F   K   | ]  }|j                   t        u s|  y wr(   )rZ   r/   r{   s     r   r~   zfields.<locals>.<genexpr>  s     Gqq}}/FGs   !!)re   r  AttributeErrorr   r   r  )class_or_instancer   s     r   r   r     sP    V*G4 GFMMOGGG  VJKQUUVs	   2 Ac                 4    t        t        |       t              S )z2Returns True if obj is an instance of a dataclass.)r  rG   r  )objs    r   _is_dataclass_instancer\  	  s    49g&&r   c                 \    t        | t              r| n
t        |       }t        |t              S )zEReturns True if obj is a dataclass or an instance of a
    dataclass.)rK   rG   r  r  )r[  rO   s     r   r   r     s%     C&#DIC3  r   )dict_factoryc                F    t        |       st        d      t        | |      S )a  Return 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. Other objects are copied with 'copy.deepcopy()'.
    z0asdict() should be called on dataclass instances)r\  r   _asdict_inner)r[  r^  s     r   r   r     s%    & "#&JKKl++r   c           
         t        |       t        v r| S t        |       rt        u rFt	        |       D ci c]1  }|j
                  t        t        | |j
                        t              3 c}S g }t	        |       D ]?  }t        t        | |j
                              }|j                  |j
                  |f       A  |      S t        | t              r2t        | d      r& t        |       | D cg c]  }t        |       c} S t        | t        t        f      r t        |       fd| D              S t        | t              rt        t        |       d      rN t        |       t        | d            }| j                         D ]  \  }}t        |      |t        |      <     |S  t        |       fd| j                         D              S t        j                  |       S c c}w c c}w )N_fieldsc              3   6   K   | ]  }t        |        y wr(   r`  )r|   vr^  s     r   r~   z _asdict_inner.<locals>.<genexpr>V  s     EAq,7E   rT   c              3   T   K   | ]  \  }}t        |      t        |      f ! y wr(   rd  )r|   kre  r^  s      r   r~   z _asdict_inner.<locals>.<genexpr>_  s3      2!Q (<8'<8: 2   %()rG   _ATOMIC_TYPESr\  rD  r   r*   r`  re   r   rK   r   r  listr  copydeepcopy)r[  r^  r}   r=   r   re  rh  s    `     r   r`  r`  -  s   CyM!
		$4   gc166&:DAA 
 FC[ /%gc166&:LIqvvuo./  ''	C	GC$;( tCy3Ga=L9GHH	C$	' tCyEEEE	C	49/0 T#Yws,=>?F		 X19Fq,9W}Q56XMtCy 2%(YY[2 2 	2 }}S!!a< Hs   6G'0G,)tuple_factoryc                F    t        |       st        d      t        | |      S )a  Return 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. Other objects are copied with 'copy.deepcopy()'.
    z1astuple() should be called on dataclass instances)r\  r   _astuple_inner)r[  rn  s     r   r   r   f  s%    & "#&KLL#}--r   c           	         t        |       t        v r| S t        |       rKg }t        |       D ]3  }t	        t        | |j                              }|j                  |       5  |      S t        | t              r2t        | d      r& t        |       | D cg c]  }t	        |       c} S t        | t        t        f      r t        |       fd| D              S t        | t              r{t        |       }t        |d      rE |t        | d            }| j                         D ]  \  }}t	        |      |t	        |      <     |S  |fd| j                         D              S t        j                  |       S c c}w )Nrb  c              3   6   K   | ]  }t        |        y wr(   rp  )r|   re  rn  s     r   r~   z!_astuple_inner.<locals>.<genexpr>  s     Ga=9Grf  rT   c              3   T   K   | ]  \  }}t        |      t        |      f ! y wr(   rs  )r|   rh  re  rn  s      r   r~   z!_astuple_inner.<locals>.<genexpr>  s0      3"a (=9>!];[\ 3ri  )rG   rj  r\  r   rp  re   r*   r   rK   r   r  rk  rD  r  rl  rm  )r[  rn  r=   r}   r   re  obj_typerh  s    `      r   rp  rp  ~  sd   CyM!
		$ 	!A"73#7GEMM% 	! V$$	C	GC$; tCySI>!];IJJ	C$	' tCyG3GGG	C	98./ gc+<=>F		 \1;I!];[~a78\M 3&)iik3 3 	3 }}S!!% Js   E=r   )bases	namespacerV   rL   rl   rm   rn   ro   rp   rY   rq   rr   r   c                ,   i t               }i i |D ]  }t        |t              r|}d}n<t        |      dk(  r|\  }}n(t        |      dk(  r|\  }}}||<   nt	        d|      t        |t              r|j                         st	        d|      t        j                  |      rt	        d|      ||v rt	        d|      |j                  |       ||<    fd}t        j                  | |i |      }|	 t        j                  d	      xs d
}|||_        t'        |||||||	|
|||      S # t        $ rI 	 t        j                  d	      j                  j!                  dd
      }n# t        t"        f$ r Y nw xY wY pw xY w)a  Return 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, frozen, match_args, kw_only,
    slots, and weakref_slot are passed to dataclass().

    If module parameter is defined, the '__module__' attribute of the dataclass is
    set to that value.
    z
typing.Anyr      zInvalid field: z'Field names must be valid identifiers: z"Field names must not be keywords: zField name duplicated: c                 T    | j                         | j                         | d<   y )N__annotations__)r   )r   annotationsdefaultsrw  s    r   exec_body_callbackz*make_dataclass.<locals>.exec_body_callback  s&    
		)
		( +r   r   __main__r   rk   )rA   rK   r   lenr   isidentifierkeyword	iskeywordr:   r]   	new_classr   _getframemodulenamerX  	_getframe	f_globalsr   rw   r   r   )cls_namer   rv  rw  rV   rL   rl   rm   rn   ro   rp   rY   rq   rr   r   seenitemr*   tpspecr~  rO   r|  r}  s      `                  @@r   r   r     s   < 	 5DKH dC DBY!^ID"Y!^!ND"d!HTNodX677$$D,=,=,?EdXNOOT"@IJJ4<5dX>??D)., //(E2/A
BC ~	,,Q/=:F  St$2U!,V *G5".0 0  	q)3377
JO"J/ 	s6   	E 	F/E;:F;F
FFFFc                   t        |       st        d      t        | t              j	                         D ]  }|j
                  t        u r|j                  s(|j                  |v rt        d|j                   d      J|j                  |vsY|j
                  t        u r+|j                  t        u rt        d|j                  d      t        | |j                        ||j                  <     | j                  di |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 instancesr   zC is declared with init=False, it cannot be specified with replace()zInitVar z! must be specified with replace()r   )r\  r   re   r  r  rZ   r0   rV   r*   rw   r1   rS   r   r   )r[  changesr}   s      r   r   r     s    $ "#&KLL
 S'"))+ 3==O+vvvv  6!&& 2- "- . . 66 }}.1993G 8AFF: 6D "D E E%c1662GAFFO#30 3==#7##r   r(   )\rer   rl  r]   r  r  rB   rE  r#  r8   r   r   __all__rX  r   r   r   r!   r   r$   r
   r^   r\   r&   r/   r0   r1   r  r  r   compiler   	frozensetNoneTyper   intfloatr   complexbytesEllipsisTypeNotImplementedTypeCodeTypeBuiltinFunctionTyperG   rangepropertyrj  rD   r	   r   rj   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r3  r5  r9  r?  r"  r   r   r\  r   rD  r   r`  r   r   rp  r   r   r   r   r   <module>r     sG   	 
       
  ,| 0. /
  23 	 	
/	 	
/ )%((, 
 
X	/0-. ! ! "
 #

#AB  	NN					NN			% .$ 6=2 =2@' 'Z gDtTD'$0	F -1")8	)9;x<&8(v.'';4)8v_B70,d ,d,d -d -n	
 -d -i -d -i -o -i -o -i -o -i -o*g\94O 4n4dt5$5u>H$'
! !% ,06"r #( .0""J /1DtUD%u %dW0t0$r   