o
    诪go                    @  s  d dl m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Zd dlZd dlmZ ddlmZmZmZ ddlmZmZmZmZmZmZ ddlmZmZmZmZ ejZ dZ!d	Z"d
Z#e$i Z%e Z&e'ej(ej)Z*G dd dej+Z,e,j-Z-	 G dd de.Z/e-ddddddddddddddfddZ0dddZ1dddZ2dd Z3e3dg dZ4dd Z5dd Z6d d! Z7d"d# Z8d$d% Z9d&d' Z:d(d) Z;d*d+ Z<d,d- Z=G d.d/ d/Z>d0d1 Z?d2d3 Z@	dd4d5ZA																								dd6d7ZBeBZC	 d8d9 ZDd:d; ZEd<d= ZFd>d? ZGd@dA ZHdBdC ZIdDdE ZJddFdGZKdHdI ZLddJdKZMdLdM ZNdNdO ZOdPdQ Z)dRdS ZPdTdU ZQdd\d]ZRdd`daZSddcddZTddedfZUddkdlZVddydzZWdd|d}ZXG d~d dZYdd eYjZD Z[eGeKeMeYe[ddd e[D ddd e[D dZYG dd dZ\eKeMe\Z\G dd dZ]dd e]jZD Z^eGeKeMe]e^de^de^dZ]G dd_ d_Z_dd dD Z^eGeKeMe_e^de^de^dZ_efdfddZ`eBdddG dd dZadd Zbdd Z'dS )    )annotationsN)
itemgetter   )_compat_configsetters)PY_3_10_PLUSPY_3_11_PLUSPY_3_13_PLUS_AnnotationExtractor_get_annotationsget_generic_base)DefaultAlreadySetErrorFrozenInstanceErrorNotAnAttrsClassErrorUnannotatedAttributeErrorz__attr_factory_%s)ztyping.ClassVarz
t.ClassVarClassVarztyping_extensions.ClassVar_attrs_cached_hashc                   @  s(   e Zd ZdZe Zdd Zdd ZdS )_NothingaF  
    Sentinel to indicate the lack of a value when `None` is ambiguous.

    If extending attrs, you can use ``typing.Literal[NOTHING]`` to show
    that a value may be ``NOTHING``.

    .. versionchanged:: 21.1.0 ``bool(NOTHING)`` is now False.
    .. versionchanged:: 22.2.0 ``NOTHING`` is now an ``enum.Enum`` variant.
    c                 C     dS )NNOTHING selfr   r   F/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/attr/_make.py__repr__I      z_Nothing.__repr__c                 C  r   )NFr   r   r   r   r   __bool__L   r   z_Nothing.__bool__N)	__name__
__module____qualname____doc__enumautor   r   r   r   r   r   r   r   <   s
    
r   c                   @  s"   e Zd ZdZeddfddZdS )_CacheHashWrappera  
    An integer subclass that pickles / copies as None

    This is used for non-slots classes with ``cache_hash=True``, to avoid
    serializing a potentially (even likely) invalid hash value. Since `None`
    is the default value for uncalculated hashes, whenever this is copied,
    the copy's value for the hash should automatically reset.

    See GH #613 for more details.
    Nr   c                 C  s   ||fS Nr   )r   _none_constructor_argsr   r   r   
__reduce__d      z_CacheHashWrapper.__reduce__)r   r   r    r!   typer(   r   r   r   r   r$   X   s    r$   TFc                 C  s4  t |||d\}}}}|dur|dur|durd}t||	dur9| tur+d}t|t|	s5d}t|t|	} |du r?i }t|ttfrKt	j
| }|rXt|ttfrXt| }|ret|ttfret
| }tdi d| d|d	|d
dd|d|d|d|d|d|
d|d|d|d|d|d|S )a  
    Create a new field / attribute on a class.

    Identical to `attrs.field`, except it's not keyword-only.

    Consider using `attrs.field` in new code (``attr.ib`` will *never* go away,
    though).

    ..  warning::

        Does **nothing** unless the class is also decorated with
        `attr.s` (or similar)!


    .. versionadded:: 15.2.0 *convert*
    .. versionadded:: 16.3.0 *metadata*
    .. versionchanged:: 17.1.0 *validator* can be a ``list`` now.
    .. versionchanged:: 17.1.0
       *hash* is `None` and therefore mirrors *eq* by default.
    .. versionadded:: 17.3.0 *type*
    .. deprecated:: 17.4.0 *convert*
    .. versionadded:: 17.4.0
       *converter* as a replacement for the deprecated *convert* to achieve
       consistency with other noun-based arguments.
    .. versionadded:: 18.1.0
       ``factory=f`` is syntactic sugar for ``default=attr.Factory(f)``.
    .. versionadded:: 18.2.0 *kw_only*
    .. versionchanged:: 19.2.0 *convert* keyword argument removed.
    .. versionchanged:: 19.2.0 *repr* also accepts a custom callable.
    .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
    .. versionadded:: 19.2.0 *eq* and *order*
    .. versionadded:: 20.1.0 *on_setattr*
    .. versionchanged:: 20.3.0 *kw_only* backported to Python 2
    .. versionchanged:: 21.1.0
       *eq*, *order*, and *cmp* also accept a custom callable
    .. versionchanged:: 21.1.0 *cmp* undeprecated
    .. versionadded:: 22.2.0 *alias*
    TNF6Invalid value for hash.  Must be True, False, or None.z=The `default` and `factory` arguments are mutually exclusive.z*The `factory` argument must be a callable.default	validatorreprcmphashinit	convertermetadatar*   kw_onlyeqeq_keyorder	order_key
on_setattraliasr   )_determine_attrib_eq_order	TypeErrorr   
ValueErrorcallableFactory
isinstancelisttupler   pipeand__CountingAttr)r,   r-   r.   r/   r0   r1   r3   r*   r2   factoryr4   r5   r7   r9   r:   r6   r8   msgr   r   r   attribh   sp   7
	
rH    c                 C  s   t | |d}t||| dS )z[
    Evaluate the script with the given global (globs) and local (locs)
    variables.
    execN)compileeval)scriptglobslocsfilenamebytecoder   r   r   _compile_and_eval   s   rR   c           
      C  s   |du ri n|}d}|}	 t |d|d|f}tj||}	|	|kr$n|dd  d| d}|d7 }qt|||| ||  S )zO
    Create the method with the script given and return the method object.
    Nr   T->)len
splitlines	linecachecache
setdefaultrR   )
namerM   rP   rN   localsrO   countbase_filenamelinecache_tupleold_valr   r   r   _make_method   s"   ra   c                 C  sv   |  d}d| ddg}|r%t |D ]\}}|d| d| d qn|d ttd	}td
|| || S )z
    Create a tuple subclass to hold `Attribute`s for an `attrs` class.

    The subclass is a bare tuple with properties for names.

    class MyClassAttributes(tuple):
        __slots__ = ()
        x = property(itemgetter(0))
    
Attributeszclass z(tuple):z    __slots__ = ()    z% = _attrs_property(_attrs_itemgetter())z    pass)_attrs_itemgetter_attrs_property
)	enumerateappendr   propertyrR   join)cls_name
attr_namesattr_class_nameattr_class_templatei	attr_namerN   r   r   r   _make_attr_tuple_class   s   




rr   _Attributes)attrs
base_attrsbase_attrs_mapc                 C  s2   t | } | dr| dr| dd } | tS )z
    Check whether *annot* is a typing.ClassVar.

    The string comparison hack is used to avoid evaluating all string
    annotations which would put attrs-based classes at a performance
    disadvantage compared to plain old classes.
    )'"r   rS   )str
startswithendswith_CLASSVAR_PREFIXES)annotr   r   r   _is_class_var#  s   
r~   c                 C  s
   || j v S )zR
    Check whether *cls* defines *attrib_name* (and doesn't just inherit it).
    )__dict__)clsattrib_namer   r   r   _has_own_attribute4  s   
r   c                 C  s   g }i }t | jdd D ]$}t|dg D ]}|js|j|v r q|jdd}|| |||j< qqg }t }t |D ]}|j|v rCq;|d| |	|j q;||fS )zQ
    Collect attr.ibs from base classes of *cls*, except *taken_attr_names*.
    r   rS   __attrs_attrs__T	inheritedr   )
reversed__mro__getattrr   r[   evolveri   setinsertadd)r   taken_attr_namesru   base_attr_mapbase_clsafilteredseenr   r   r   _collect_base_attrs;  s$   

r   c                 C  sn   g }i }| j dd D ]'}t|dg D ]}|j|v rq|jdd}||j || |||j< qq||fS )a-  
    Collect attr.ibs from base classes of *cls*, except *taken_attr_names*.

    N.B. *taken_attr_names* will be mutated.

    Adhere to the old incorrect behavior.

    Notably it collects from the front and considers inherited attributes which
    leads to the buggy behavior reported in #428.
    r   rS   r   Tr   )r   r   r[   r   r   ri   )r   r   ru   r   r   r   r   r   r   _collect_base_attrs_brokenZ  s   

	r   c              	     s  | j t|  |durt| }np|du rsdd  D }g }t }  D ],\}	}
t|
r1q(||	 |	t}t	|t
sM|tu rHt nt|d}||	|f q(|| }t|dkrrtddt|fd	d
d d ntdd  D dd
 d} fdd|D }|rt| dd |D \}}nt| dd |D \}}|rdd |D }dd |D }|| }d}dd |D D ]}|du r|jtu rd|}t||du r|jturd}q|dur|| |}dd |D }dd |D }t| j|}t||||fS )a3  
    Transform all `_CountingAttr`s on a class into `Attribute`s.

    If *these* is passed, use that and don't look for them on the class.

    If *collect_by_mro* is True, collect them in the correct MRO order,
    otherwise use the old -- incorrect -- order.  See #428.

    Return an `_Attributes`.
    NTc                 S  s   h | ]\}}t |tr|qS r   r@   rE   .0r[   attrr   r   r   	<setcomp>  s    z#_transform_attrs.<locals>.<setcomp>r,   r   z1The following `attr.ib`s lack a type annotation: , c                   s     | jS r%   )getcounter)n)cdr   r   <lambda>  s    z"_transform_attrs.<locals>.<lambda>)key.c                 s  s&    | ]\}}t |tr||fV  qd S r%   r   r   r   r   r   	<genexpr>  s    
z#_transform_attrs.<locals>.<genexpr>c                 S  s
   | d j S Nr   )r   )er   r   r   r        
 c                   s&   g | ]\}}t j|| |d qS ))r[   car*   )	Attributefrom_counting_attrr   )r   rq   r   )annsr   r   
<listcomp>  s    z$_transform_attrs.<locals>.<listcomp>c                 S     h | ]}|j qS r   r[   r   r   r   r   r   r         c                 S  r   r   r   r   r   r   r   r     r   c                 S     g | ]}|j d dqS T)r4   r   r   r   r   r   r         c                 S  r   r   r   r   r   r   r   r     r   Fc                 s  s(    | ]}|j d ur|jd u r|V  qdS )FN)r1   r4   r   r   r   r   r     s   & zlNo mandatory attributes allowed after an attribute with a default value or factory.  Attribute in question: c                 S  s(   g | ]}|j s|jt|jd n|qS ))r:   )r:   r   _default_init_alias_forr[   r   r   r   r   r     s    c                 S  s   g | ]}|j qS r   r   r   r   r   r   r     r   )r   r   rA   itemsr   r~   r   r   r   r@   rE   rH   ri   rV   r   rk   sortedr   r   r,   r=   rr   r   rs   )r   theseauto_attribsr4   collect_by_mrofield_transformerca_listca_namesannot_namesrq   r*   r   unannotated	own_attrsru   r   rt   had_defaultrG   rm   
AttrsClassr   )r   r   r   _transform_attrsv  s   

	
	


r   c                 C  sl   g d}|d ur| d n|g d |ddg t|d}| tj|d}tdd	|||d
|idS )N)	zdef wrapper(_cls):z    __class__ = _clsz    def __getattr__(self, item, cached_properties=cached_properties, original_getattr=original_getattr, _cached_setattr_get=_cached_setattr_get):z+         func = cached_properties.get(item)z         if func is not None:z!              result = func(self)z1              _setter = _cached_setattr_get(self)z#              _setter(item, result)z              return resultz,         return original_getattr(self, item))z         try:z2             return super().__getattribute__(item)z         except AttributeError:z4             if not hasattr(super(), '__getattr__'):z                 raisez-             return super().__getattr__(item)zY         original_error = f"'{self.__class__.__name__}' object has no attribute '{item}'"z-         raise AttributeError(original_error)z    return __getattr__z__getattr__ = wrapper(_cls)r   )cached_properties_cached_setattr_getoriginal_getattr__getattr__rg   _cls)r\   )ri   extend_generate_unique_filename_OBJ_SETATTR__get__ra   rk   )r   r   r   linesunique_filenameglobr   r   r   _make_cached_property_getattr  s4   
r   c                 C  s(   t | tr|dv rt| || dS t)z4
    Attached to frozen classes as __setattr__.
    )	__cause____context____traceback____suppress_context__	__notes__N)r@   BaseException__setattr__r   r   r[   valuer   r   r   _frozen_setattrs  s   r   c                 C  s&   t | tr|dv rt| | dS t)z4
    Attached to frozen classes as __delattr__.
    )r   N)r@   r   __delattr__r   )r   r[   r   r   r   _frozen_delattrs.  s   r   c            	      O  s   z| \}W n t y   dt|  d}t|dw |j}t|}|D ]}|js)q#|j}|j}||vr:t||||< q#|di |S )a  
    Create a new instance, based on the first positional argument with
    *changes* applied.

    .. tip::

       On Python 3.13 and later, you can also use `copy.replace` instead.

    Args:

        inst:
            Instance of a class with *attrs* attributes. *inst* must be passed
            as a positional argument.

        changes:
            Keyword changes in the new copy.

    Returns:
        A copy of inst with *changes* incorporated.

    Raises:
        TypeError:
            If *attr_name* couldn't be found in the class ``__init__``.

        attrs.exceptions.NotAnAttrsClassError:
            If *cls* is not an *attrs* class.

    .. versionadded:: 17.1.0
    .. deprecated:: 23.1.0
       It is now deprecated to pass the instance using the keyword argument
       *inst*. It will raise a warning until at least April 2024, after which
       it will become an error. Always pass the instance as a positional
       argument.
    .. versionchanged:: 24.1.0
       *inst* can't be passed as a keyword argument anymore.
    z*evolve() takes 1 positional argument, but z were givenNr   )	r=   rV   r<   	__class__fieldsr1   r[   r:   r   )	argschangesinstrG   r   rt   r   rq   	init_namer   r   r   r   9  s$   %

r   c                   @  s   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'S )(_ClassBuilderz(
    Iteratively build *one* class.
    )_attr_names_attrs_base_attr_map_base_names_cache_hashr   	_cls_dict_delete_attribs_frozen_has_custom_setattr_has_post_init_has_pre_init_is_exc_on_setattr_pre_init_has_args_slots_weakref_slot_wrote_own_setattrc                 C  s  t ||||||\}}}|| _|rt|jni | _|| _dd |D | _|| _tdd |D | _	|| _
|| _|| _|	| _tt|dd| _d| _| jr\|j}t|}t|jdk| _tt|dd| _t| | _|
| _|| _|| _d| _| j| jd	< |rt| jd
< t| jd< d| _n?|tt j!t j"fv rd }}|D ]}|j#d urd}|j$d urd}|r|r nq|tkr|s|r|t j!kr|r|t j"kr|sd | _|r| % \| jd< | jd< d S d S )Nc                 S  r   r   r   r   r   r   r   r     r   z)_ClassBuilder.__init__.<locals>.<setcomp>c                 s  s    | ]}|j V  qd S r%   r   r   r   r   r   r     s    z)_ClassBuilder.__init__.<locals>.<genexpr>__attrs_pre_init__Fr   __attrs_post_init__r   r   r   T__getstate____setstate__)&r   r   dictr   r   r   r   r   rB   r   r   r   r   r   boolr   r   r   r   inspect	signaturerV   
parametersr   r   r   r   r   r   r   r   _DEFAULT_ON_SETATTRr   validateconvertr-   r2   _make_getstate_setstate)r   r   r   slotsfrozenweakref_slotgetstate_setstater   r4   
cache_hashis_excr   r9   has_custom_setattrr   rt   ru   base_mappre_init_funcpre_init_signaturehas_validatorhas_converterr   r   r   r   __init__  s~   
	




z_ClassBuilder.__init__c                 C  s   d| j j dS )Nz<_ClassBuilder(cls=z)>)r   r   r   r   r   r   r     s   z_ClassBuilder.__repr__c                 C  sL   | j du r
|  }n|  }trt|}t|ddr$d|jvr$|  |S )z
        Finalize class based on the accumulated configuration.

        Builder cannot be used after calling this method.
        T__attrs_init_subclass__N)	r   _create_slots_class_patch_original_classr   abcupdate_abstractmethodsr   r   r  )r   r   r   r   r   build_class  s   




z_ClassBuilder.build_classc              	   C  s   | j }| j}| jr5| jD ](}||vr4t||ttur4tt t	|| W d   n1 s/w   Y  q| j
 D ]
\}}t||| q:| jsWt|ddrWd|_| jsWt|_|S )zA
        Apply accumulated methods and return the class.
        N__attrs_own_setattr__F)r   r   r   r   r   	_SENTINEL
contextlibsuppressAttributeErrordelattrr   r   setattrr   r  r   r   r   )r   r   
base_namesr[   r   r   r   r   r    s&   
z#_ClassBuilder._patch_original_classc              
     s  fddj  D }js*d|d< js*jjD ]  jddr)t|d<  nqi }d}jj	dd D ]  jdd	d	urCd
}|
 fddt dg D  q6tjj}jrrdtjddvrrd|vrr|sr|d7 }dd | D }g }|rtj}| D ]!\}}	||f7 }||= ||	 t|	j}
|
tjjur|
||< q|d}|d	ur|| t||j|d< fdd|D fdd| D fddD |
 jrt t|d< jj|d< tjjjjj|}t|j  |D ]L}t!|t"t#frt|j$dd	}nt!|t%r-t|j&dd	}nt|dd	}|s8q|D ]}z|j'ju }W n t(yO   Y q:w |rV||_'q:q|S )zL
        Build and return a new class with a `__slots__` attribute.
        c                   s2   i | ]\}}|g t  jd dR vr||qS )r   __weakref__)rB   r   r   kvr   r   r   
<dictcomp>+  s
    z5_ClassBuilder._create_slots_class.<locals>.<dictcomp>Fr  r   r   rS   r  NTc                      i | ]}|t  |qS r   r   r   r[   )r   r   r   r   J  s    
	__slots__r   )r  c                 S  s$   i | ]\}}t |tjr||jqS r   )r@   	functoolscached_propertyfunc)r   r[   r&  r   r   r   r   [  s    
r   c                      g | ]}| vr|qS r   r   r#  )r  r   r   r   z  r   z5_ClassBuilder._create_slots_class.<locals>.<listcomp>c                   s   i | ]\}}| v r||qS r   r   )r   slotslot_descriptor)
slot_namesr   r   r     s
    c                   r(  r   r   r#  )reused_slotsr   r   r     r   r    __closure__))r   r   r   r   r   	__bases__r   r   r   r   updater   r   r   r   r   r   ri   r   r   return_annotation	Parameteremptyr   r   _HASH_CACHE_FIELDrB   r    r*   r   	itertoolschainvaluesr@   classmethodstaticmethod__func__rj   fgetcell_contentsr=   )r   r   existing_slotsweakref_inheritednamesr   &additional_closure_functions_to_updateclass_annotationsr[   r'  
annotationr   r   itemclosure_cellscellmatchr   )r   r  r,  r   r+  r   r  '  s   












	z!_ClassBuilder._create_slots_classc                 C  s    |  t| j|| j| jd< | S )Nr   )_add_method_dunders
_make_reprr   r   r   )r   nsr   r   r   add_repr  s   
z_ClassBuilder.add_reprc                 C  s<   | j d}|d u rd}t|dd }| || j d< | S )Nr   z3__str__ can only be generated if a __repr__ exists.c                 S  s   |   S r%   r   r   r   r   r   __str__  r)   z&_ClassBuilder.add_str.<locals>.__str__rK  )r   r   r=   rF  )r   r.   rG   rK  r   r   r   add_str  s   z_ClassBuilder.add_strc                   s<   t dd | jD fdd}| j  fdd}||fS )zF
        Create custom __setstate__ and __getstate__ methods.
        c                 s  s    | ]	}|d kr|V  qdS )r  Nr   )r   anr   r   r   r     s    z8_ClassBuilder._make_getstate_setstate.<locals>.<genexpr>c                   s    fddD S )9
            Automatically created by attrs.
            c                   r!  r   r"  r#  r   r   r   r     r   zQ_ClassBuilder._make_getstate_setstate.<locals>.slots_getstate.<locals>.<dictcomp>r   r   )state_attr_namesr   r   slots_getstate     z=_ClassBuilder._make_getstate_setstate.<locals>.slots_getstatec                   sj   t | }t|trt|D ]	\}}||| qnD ]}||v r)||||  q r3|td dS dS )rN  N)r   r   r@   rB   zipr3  )r   state_ClassBuilder__bound_setattrr[   r   hash_caching_enabledrO  r   r   slots_setstate  s   

z=_ClassBuilder._make_getstate_setstate.<locals>.slots_setstate)rB   r   r   )r   rP  rW  r   rU  r   r     s   z%_ClassBuilder._make_getstate_setstatec                 C  s   d | j d< | S )N__hash__)r   r   r   r   r   make_unhashable  s   
z_ClassBuilder.make_unhashablec                 C  s(   |  t| j| j| j| jd| jd< | S )Nr  r  rX  )rF  
_make_hashr   r   r   r   r   r   r   r   r   add_hash  s   
	z_ClassBuilder.add_hashc                 C  F   |  t| j| j| j| j| j| j| j| j	| j
| j| jdd| jd< | S )NF
attrs_initr  rF  
_make_initr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   add_init  "   
z_ClassBuilder.add_initc                 C  s   |  dd | jd< | S )Nc                 [  s   t | fi |S r%   r   )r   r   r   r   r   r     s    z+_ClassBuilder.add_replace.<locals>.<lambda>__replace__)rF  r   r   r   r   r   add_replace  s   
z_ClassBuilder.add_replacec                 C  s   t dd | jD | jd< d S )Nc                 s  s"    | ]}|j r|js|jV  qd S r%   )r1   r4   r[   )r   fieldr   r   r   r     s    
z/_ClassBuilder.add_match_args.<locals>.<genexpr>__match_args__)rB   r   r   r   r   r   r   add_match_args  s   z_ClassBuilder.add_match_argsc                 C  r]  )NTr^  __attrs_init__r`  r   r   r   r   add_attrs_init  rc  z_ClassBuilder.add_attrs_initc                 C  s2   | j }| t| j| j|d< | t |d< | S )N__eq____ne__)r   rF  _make_eqr   r   _make_ner   r   r   r   r   add_eq2  s   z_ClassBuilder.add_eqc                   s>    j } fddt j jD \|d< |d< |d< |d<  S )Nc                 3  s    | ]}  |V  qd S r%   )rF  )r   methr   r   r   r   ?  s
    
z*_ClassBuilder.add_order.<locals>.<genexpr>__lt____le____gt____ge__)r   _make_orderr   r   ro  r   r   r   	add_order<  s
   
z_ClassBuilder.add_orderc                   s   | j r| S i  | jD ]}|jp| j}|r |tjur ||f |j< q
 s%| S | jr.d}t| fdd}d| j	d< | 
|| j	d< d| _| S )Nz7Can't combine custom __setattr__ with on_setattr hooks.c                   sD   z | \}}W n t y   |}Y nw || ||}t| || d S r%   )KeyErrorr   )r   r[   valr   hooknvalsa_attrsr   r   r   Y  s   z._ClassBuilder.add_setattr.<locals>.__setattr__Tr  r   )r   r   r9   r   r   NO_OPr[   r   r=   r   rF  r   )r   r   r9   rG   r   r   r|  r   add_setattrF  s$   


z_ClassBuilder.add_setattrc                 C  s   t t | jj|_W d   n1 sw   Y  t t | jj d|j |_W d   n1 s5w   Y  t t d| jj d|_W d   |S 1 sTw   Y  |S )zL
        Add __module__ and __qualname__ to a *method* if possible.
        Nr   z$Method generated by attrs for class )r  r  r  r   r   r    r   r!   )r   methodr   r   r   rF  i  s   
z!_ClassBuilder._add_method_dundersN)r   r   r    r!   r$  r  r   r  r  r  rI  rL  r   rY  r\  rb  re  rh  rj  rp  rw  r  rF  r   r   r   r   r   s  s,    \$ )

#r   c                 C  st   | durt |du|dufrd}t|| dur| | fS |du r"|}|du r(|}|du r6|du r6d}t|||fS )
    Validate the combination of *cmp*, *eq*, and *order*. Derive the effective
    values of eq and order.  If *eq* is None, set it to *default_eq*.
    N&Don't mix `cmp` with `eq' and `order`.FT-`order` can only be True if `eq` is True too.anyr=   )r/   r5   r7   
default_eqrG   r   r   r   _determine_attrs_eq_order|  s   r  c           	      C  s   | durt |du|dufrd}t|dd }| dur(|| \} }| || |fS |du r2|d}}n||\}}|du rB||}}n||\}}|du rV|du rVd}t|||||fS )r  Nr  c                 S  s&   t | rd| } }| |fS d}| |fS )z8
        Decide whether a key function is used.
        TN)r>   )r   r   r   r   r   decide_callable_or_boolean  s
   
z>_determine_attrib_eq_order.<locals>.decide_callable_or_booleanFTr  r  )	r/   r5   r7   r  rG   r  cmp_keyr6   r8   r   r   r   r;     s"   r;   c                 C  sF   |du s|du r
|S |du r|du r|S |D ]
}t | |r  dS q|S )ap  
    Check whether we should implement a set of methods for *cls*.

    *flag* is the argument passed into @attr.s like 'init', *auto_detect* the
    same as passed into @attr.s and *dunders* is a tuple of attribute names
    whose presence signal that the user has implemented it themselves.

    Return *default* if no reason for either for or against is found.
    TFN)r   )r   flagauto_detectdundersr,   dunderr   r   r   _determine_whether_to_implement  s   
r  c                   s   durddl }|jtddd t|||d\|dur |	tttfr,tj  	
fdd}| du rL|S || S )a  
    A class decorator that adds :term:`dunder methods` according to the
    specified attributes using `attr.ib` or the *these* argument.

    Consider using `attrs.define` / `attrs.frozen` in new code (``attr.s`` will
    *never* go away, though).

    Args:
        repr_ns (str):
            When using nested classes, there was no way in Python 2 to
            automatically detect that.  This argument allows to set a custom
            name for a more meaningful ``repr`` output.  This argument is
            pointless in Python 3 and is therefore deprecated.

    .. caution::
        Refer to `attrs.define` for the rest of the parameters, but note that they
        can have different defaults.

        Notably, leaving *on_setattr* as `None` will **not** add any hooks.

    .. versionadded:: 16.0.0 *slots*
    .. versionadded:: 16.1.0 *frozen*
    .. versionadded:: 16.3.0 *str*
    .. versionadded:: 16.3.0 Support for ``__attrs_post_init__``.
    .. versionchanged:: 17.1.0
       *hash* supports `None` as value which is also the default now.
    .. versionadded:: 17.3.0 *auto_attribs*
    .. versionchanged:: 18.1.0
       If *these* is passed, no attributes are deleted from the class body.
    .. versionchanged:: 18.1.0 If *these* is ordered, the order is retained.
    .. versionadded:: 18.2.0 *weakref_slot*
    .. deprecated:: 18.2.0
       ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now raise a
       `DeprecationWarning` if the classes compared are subclasses of
       each other. ``__eq`` and ``__ne__`` never tried to compared subclasses
       to each other.
    .. versionchanged:: 19.2.0
       ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now do not consider
       subclasses comparable anymore.
    .. versionadded:: 18.2.0 *kw_only*
    .. versionadded:: 18.2.0 *cache_hash*
    .. versionadded:: 19.1.0 *auto_exc*
    .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
    .. versionadded:: 19.2.0 *eq* and *order*
    .. versionadded:: 20.1.0 *auto_detect*
    .. versionadded:: 20.1.0 *collect_by_mro*
    .. versionadded:: 20.1.0 *getstate_setstate*
    .. versionadded:: 20.1.0 *on_setattr*
    .. versionadded:: 20.3.0 *field_transformer*
    .. versionchanged:: 21.1.0
       ``init=False`` injects ``__attrs_init__``
    .. versionchanged:: 21.1.0 Support for ``__attrs_pre_init__``
    .. versionchanged:: 21.1.0 *cmp* undeprecated
    .. versionadded:: 21.3.0 *match_args*
    .. versionadded:: 22.2.0
       *unsafe_hash* as an alias for *hash* (for :pep:`681` compliance).
    .. deprecated:: 24.1.0 *repr_ns*
    .. versionchanged:: 24.1.0
       Instances are not compared as tuples of attributes anymore, but using a
       big ``and`` condition. This is faster and has more correct behavior for
       uncomparable values like `math.nan`.
    .. versionadded:: 24.1.0
       If a class has an *inherited* classmethod called
       ``__attrs_init_subclass__``, it is executed after the class is created.
    .. deprecated:: 24.1.0 *hash* is deprecated in favor of *unsafe_hash*.
    Nr   zQThe `repr_ns` argument is deprecated and will be removed in or after August 2025.   )
stacklevelc                   s  pt | }du ot| t}ot| d}|r |r d}t|t| |t| dd ||}t| drD| du rL|  t| d}|s]|du r]|	  |sjt| drj|
  |  	d u r}du r}t| d	r}d
		dur	d
ur	d urd}t|	d
u s	d u r|d
u s|rrd}t|n!	du s	d u r|du r|du r|  nrd}t||  t| 
dr|  n|  rd}t|trt| ds|  trrt| ds|  | S )NTr   z/Can't freeze a class with a custom __setattr__.)r   r   r   rJ  )rk  rl  )rr  rs  rt  ru  rX  Fr+   zlInvalid value for cache_hash.  To use hash caching, hashing must be either explicitly or implicitly enabled.r  zFInvalid value for cache_hash.  To use hash caching, init must be True.rd  rg  )_has_frozen_base_class
issubclassr   r   r=   r   r  rI  rL  rp  rw  r  r<   r\  rY  rb  rj  r
   re  r   rh  r  )r   	is_frozenr  has_own_setattrrG   builderr5   r   r  auto_excr  r   eq_r   r  r  r0   r1   r4   
match_argsr9   order_r.   repr_nsr  ry   r   r  r   r   wrapL  s   


zattrs.<locals>.wrap)	warningswarnDeprecationWarningr  r@   rA   rB   r   rC   )	maybe_clsr   r  r.   r/   r0   r1   r  r  r  ry   r   r4   r  r  r5   r7   r  r   r  r9   r   r  unsafe_hashr  r  r   r  r   rt     s"   \
4krt   c                 C  s
   | j tu S )zV
    Check whether *cls* has a frozen ancestor by looking at its
    __setattr__.
    )r   r   )r   r   r   r   r    s   
r  c              	   C  s$   d| d| j  dt| d| j dS )zF
    Create a "filename" suitable for a function being generated.
    z<attrs generated  r   r    rU   )r   r   r   )r   	func_namer   r   r   r     s   r   c           	        s  t dd  D  d}t| d}t|i d}dd|s#|d7 }n|d	7 }|d
7 }d d7 |g fdd}|r{|dt d  |re|dt d|d  |d d  n|dt d|d  |dt   n|d| d}td||S )Nc                 s  s2    | ]}|j d u s|j du r|jd u r|V  qdS )TN)r0   r5   r   r   r   r   r     s    (z_make_hash.<locals>.<genexpr>        r0   zdef __hash__(selfzhash((rd   z):z, *zC, _cache_wrapper=__import__('attr._make')._make._CacheHashWrapper):z_cache_wrapper()c              	     s    ||   |d d g  D ]-}|jr4d|j d}|j|< |d| d|j d  q|d|j d  q|d   d	S )
z
        Generate the code for actually computing the hash code.
        Below this will either be returned directly or used to compute
        a value which is then cached, depending on the value of cache_hash
        r  ,__key(self.z),        self.rc   N)r   r6   r[   ri   )prefixindentr   cmp_namert   closing_bracesrN   	hash_funcmethod_lines	type_hashr   r   append_hash_computation_lines  s   

z1_make_hash.<locals>.append_hash_computation_lineszif self.z	 is None:zobject.__setattr__(self, '', r  self. = zreturn self.zreturn rg   rX  )rB   r   r0   ri   r3  rk   ra   )	r   rt   r  r  tabr   hash_defr  rM   r   r  r   r[    s@   



r[  c                 C  s   t | |ddd| _| S )z%
    Add a hash method to *cls*.
    FrZ  )r[  rX  r   rt   r   r   r   	_add_hash  s   r  c                  C  s   dd } | S )z
    Create __ne__ method.
    c                 S  s   |  |}|tu rtS | S )zj
        Check equality and either forward a NotImplemented or
        return the result negated.
        )rk  NotImplemented)r   otherresultr   r   r   rl  *  s   
z_make_ne.<locals>.__ne__r   )rl  r   r   r   rn  %  s   rn  c                 C  s   dd |D }t | d}g d}i }|rd|d |D ]B}|jrAd|j d}|j||< |d| d	|j d
| d|j d	 n|d|j d|j  ||d ur]|d  d|d< q|d n|d d|}td|||S )z6
    Create __eq__ method for *cls* with *attrs*.
    c                 S     g | ]}|j r|qS r   )r5   r   r   r   r   r   <      z_make_eq.<locals>.<listcomp>r5   )zdef __eq__(self, other):z-    if other.__class__ is not self.__class__:z        return NotImplementedz    return  (r  r  r  r  z) == z(other.r  r  z
 == other.rS   z andz    )z    return Truerg   rk  )r   ri   r6   r[   rk   ra   )r   rt   r   r   rN   r   r  rM   r   r   r   rm  8  s*   


 

rm  c                   sV   dd  D   fddfdd}fdd}fd	d
}fdd}||||fS )z9
    Create ordering methods for *cls* with *attrs*.
    c                 S  r  r   )r7   r   r   r   r   r   b  r  z_make_order.<locals>.<listcomp>c                   s    t dd  fddD D S )z&
        Save us some typing.
        c                 s  s$    | ]\}}|r||n|V  qd S r%   r   )r   r   r   r   r   r   r   h  s
    
z6_make_order.<locals>.attrs_to_tuple.<locals>.<genexpr>c                 3  s"    | ]}t  |j|jfV  qd S r%   )r   r[   r8   r   objr   r   r   j  s    
)rB   r  rt   r  r   attrs_to_tupled  s
   
z#_make_order.<locals>.attrs_to_tuplec                   s    |j | j u r |  |k S tS z1
        Automatically created by attrs.
        r   r  r   r  r  r   r   rr  o     z_make_order.<locals>.__lt__c                   s    |j | j u r |  |kS tS r  r  r  r  r   r   rs  x  r  z_make_order.<locals>.__le__c                   s    |j | j u r |  |kS tS r  r  r  r  r   r   rt    r  z_make_order.<locals>.__gt__c                   s    |j | j u r |  |kS tS r  r  r  r  r   r   ru    r  z_make_order.<locals>.__ge__r   )r   rt   rr  rs  rt  ru  r   )rt   r  r   rv  ^  s   				rv  c                 C  s&   |du r| j }t| || _t | _| S )z5
    Add equality methods to *cls* with *attrs*.
    N)r   rm  rk  rn  rl  r  r   r   r   _add_eq  s
   r  c                 C  s   t |d}tdd | D }dd |D }t|d< t|d< t|d< g }|D ]'\}}}	|	r0d	| nd
| d }
|tkr@d||
f nd|||
f }|| q%d|}|d u rYd}n|d }ddddddddddddd| d| ddd g}td!d"|||d#S )$Nr.   c                 s  s8    | ]}|j d ur|j|j du rt n|j |jfV  qdS )FTN)r.   r[   r1   r   r   r   r   r     s    
z_make_repr.<locals>.<genexpr>c                 S  s$   i | ]\}}}|t kr|d  |qS )_repr)r.   )r   r[   rr  r   r   r   r     s    z_make_repr.<locals>.<dictcomp>r   r  r   r  zgetattr(self, "z", NOTHING)z	%s={%s!r}z%s={%s_repr(%s)}r   z1{self.__class__.__qualname__.rsplit(">.", 1)[-1]}z.{self.__class__.__name__}zdef __repr__(self):z  try:z:    already_repring = _compat.repr_context.already_repringz  except AttributeError:z!    already_repring = {id(self),}z:    _compat.repr_context.already_repring = already_repringz  else:z#    if id(self) in already_repring:z      return '...'z	    else:z#      already_repring.add(id(self))z    return f'(z)'z
  finally:z$    already_repring.remove(id(self))r   rg   )rN   )	r   rB   r   r  r   r.   ri   rk   ra   )rt   rH  r   r   attr_names_with_reprsrN   attribute_fragmentsr[   r  rp   accessorfragmentrepr_fragmentcls_name_fragmentr   r   r   r   rG    sT   

rG  c                 C  s    |du r| j }t||| | _| S )z%
    Add a repr method to *cls*.
    N)r   rG  r   )r   rH  rt   r   r   r   	_add_repr  s   r  c                 C  sv   t | }|du rt| tsd}t|t| dd}|du r9|dur0t|dd}|dur0|| _|S | d}t||S )aG  
    Return the tuple of *attrs* attributes for a class.

    The tuple also allows accessing the fields by their names (see below for
    examples).

    Args:
        cls (type): Class to introspect.

    Raises:
        TypeError: If *cls* is not a class.

        attrs.exceptions.NotAnAttrsClassError:
            If *cls* is not an *attrs* class.

    Returns:
        tuple (with name accessors) of `attrs.Attribute`

    .. versionchanged:: 16.2.0 Returned tuple allows accessing the fields
       by name.
    .. versionchanged:: 23.1.0 Add support for generic classes.
    NPassed object must be a class.r   ! is not an attrs-decorated class.)r   r@   r*   r<   r   r   r   )r   generic_baserG   rt   r   r   r   r     s   
r   c                 C  sJ   t | tsd}t|t| dd}|du r| d}t|dd |D S )a  
    Return an ordered dictionary of *attrs* attributes for a class, whose keys
    are the attribute names.

    Args:
        cls (type): Class to introspect.

    Raises:
        TypeError: If *cls* is not a class.

        attrs.exceptions.NotAnAttrsClassError:
            If *cls* is not an *attrs* class.

    Returns:
        dict[str, attrs.Attribute]: Dict of attribute name to definition

    .. versionadded:: 18.1.0
    r  r   Nr  c                 S  s   i | ]}|j |qS r   r   r   r   r   r   r   /      zfields_dict.<locals>.<dictcomp>)r@   r*   r<   r   r   )r   rG   rt   r   r   r   fields_dict  s   

r  c                 C  sD   t jdu rdS t| jD ]}|j}|dur|| |t| |j qdS )z
    Validate all attributes on *inst* that have a validator.

    Leaves all exceptions through.

    Args:
        inst: Instance of a class with *attrs* attributes.
    FN)r   _run_validatorsr   r   r-   r   r[   )r   r   r  r   r   r   r   2  s   
	r   c                 C  s   | | }|od|jv S )z>
    Check if the attribute name comes from a slot class.
    r$  )r   r   )a_namer   r   r   r   r   _is_slot_attrD  s   
r  c                 C  s2  |
d uo|
t ju}|r|rd}t||p|}g }i }|D ]1}|js(|jtu r(q|| |||j< |jd urD|du rAd}t|d}q|rN|jt jurNd}qt	| d}t
|||||||||	|||rddnd\}}}| jtjv rz|tj| j j |t|d |rtj|d< t|rdnd|||}||_|S )Nz$Frozen classes can't use on_setattr.Tr1   ri  r  )r   	attr_dictr   )r   r~  r=   r1   r,   r   ri   r[   r9   r   _attrs_to_init_scriptr   sysmodulesr/  r   r   r   ra   __annotations__)r   rt   pre_initpre_init_has_args	post_initr  r  r  r   r  cls_on_setattrr_  has_cls_on_setattrrG   needs_cached_setattrfiltered_attrsr  r   r   rM   rN   r   r1   r   r   r   ra  L  sb   







ra  rq   ry   	value_varhas_on_setattrr   returnc                 C  s   d|  d| dS )zJ
    Use the cached object.setattr to set *attr_name* to *value_var*.
    
_setattr('r  r  r   rq   r  r  r   r   r   _setattr  rQ  r  r2   	Converterc                 C  s   d|  d| | | dS )zk
    Use the cached object.setattr to set *attr_name* to *value_var*, but run
    its converter first.
    r  r  r  )_fmt_converter_callrq   r  r  r2   r   r   r   _setattr_with_converter  s   r  r   c                 C  s    |rt | |dS d|  d| S )zo
    Unless *attr_name* has an on_setattr hook, use normal assignment. Otherwise
    relegate to _setattr.
    Tr  r  )r  )rq   r   r  r   r   r   _assign  s   r  c                 C  s*   |r	t | |d|S d|  d|| | S )z
    Unless *attr_name* has an on_setattr hook, use normal assignment after
    conversion. Otherwise relegate to _setattr_with_converter.
    Tr  r  )r  r  r  r   r   r   _assign_with_converter  s   r  r  r  r   dict[str, type]c                   sJ   | du r |du rdt tfS d fd	d
}d fdd}d||fS dttfS )zg
    Determine the correct setter functions based on whether a class is frozen
    and/or slotted.
    Tr   rq   ry   r  r  r   r  c                   s&   t |  rt| ||S d|  d| S N_inst_dict['z'] = )r  r  r  r   r   r   
fmt_setter  s   
z&_determine_setters.<locals>.fmt_setterr2   r  c                   s4   |st |  rt| |||S d|  d|| | S r  )r  r  r  r  r  r   r   fmt_setter_with_converter  s
   z5_determine_setters.<locals>.fmt_setter_with_converter)z_inst_dict = self.__dict__Nrq   ry   r  ry   r  r   r  ry   
rq   ry   r  ry   r  r   r2   r  r  ry   )r  r  r  r  )r  r  r   r  r  r   r  r   _determine_setters  s   

r  list[Attribute]r  
is_slottedcall_pre_initr  call_post_initdoes_cache_hashr  r  r  method_nametuple[str, dict, dict]c           $   
   C  s  |rdgng }|	r| d t|||\}}}|| g }g }g }i }ddi}| D ]}|jr5| | |j}|jdupD|jtjuoD|
}|j}t	|j
t}|rV|j
jrVdnd}|jdurit	|jtsit|j}n|j}|jdu r|rt|jf }|dur| |||d| d	 || |j|||j< n| |||d| d	 | |j
j||< n|dur| ||d
| d|| |j|||j< n| ||d
| d| n|j
tur|s| d| d}|jr| | n| | |dur| ||||| |j|||j< n| |||| n|r| d}|jr-| | n| | | d| d t|jf }|durs| d|||||  | d | d|||d | d	 ||  |j|||j< n!| d||||  | d | d|||d | d	 |  |j
j||< n1|jr| | n| | |dur| ||||| |j|||j< n	| |||| |jdu r|jdur|du r|j||< q*|dur|jr|j||< q*|r't|d< | d |D ]&}d|j }d|j }| d| d| d|j d	 |j||< |||< q |r/| d |rQ|rF|r?dt d}ndt d}ndt d}| | |rgd d!d" | D } | d#|  d	 d$|}|}!|r||rwd$nd d%d$| 7 }d$d&d' d(d" |D D }"|!|!rd$nd7 }!|!|"7 }!|r|rd)|! d	|d*< d+}#d,| d| d-|r|#|nd. d/||fS )0z
    Return a script of an initializer for *attrs*, a dict of globals, and
    annotations for the initializer.

    The globals are required by the generated script.
    zself.__attrs_pre_init__()z$_setattr = _cached_setattr_get(self)r  Nr   rI   Fr  r  zattr_dict['z
'].defaultz=attr_dict['z=NOTHINGzif z is not NOTHING:rc   zelse:Tr   z#if _config._run_validators is True:__attr_validator___attr_z(self, z, self.zself.__attrs_post_init__()r  z', None)r  z	'] = Noner  z = Noner  c                 s  s"    | ]}|j rd |j V  qdS )r  N)r1   r[   r   r   r   r   r     s     z(_attrs_to_init_script.<locals>.<genexpr>zBaseException.__init__(self, r   z*, c                 S  s   g | ]	}| d | qS )=r   )r   kw_arg_namer   r   r   r     s    z)_attrs_to_init_script.<locals>.<listcomp>c                 s  s    | ]
}| d d V  qdS )r  r   N)split)r   kwar   r   r   r     s    zself.__attrs_pre_init__(r   z
    zdef z):
    passrg   )ri   r  r   r-   r[   r9   r   r~  r:   r@   r,   r?   
takes_selfr2   r  r1   _INIT_FACTORY_PAT_get_global_namerF   r   r4   r*   _first_param_typer   r3  rk   )$rt   r  r  r   r  r  r  r   r  r  r  r  r   extra_linesr  r  r   kw_only_argsattrs_to_validatenames_for_globalsr   r   rq   r  arg_namehas_factory
maybe_selfr2   init_factory_nameargval_nameinit_hash_cachevalspre_init_argspre_init_kw_only_argsNLr   r   r   r    sl  





	
	














 



"r  r[   c                 C  s
   |  dS )z
    The default __init__ parameter name for a field.

    This performs private-name adjustment via leading-unscore stripping,
    and is the default value of Attribute.alias if not provided.
    r  )lstripr   r   r   r   r     s   
r   c                   @  sh   e Zd ZdZdZ										dddZdd Zedd	d
Zdd Z	dd Z
dd Zdd ZdS )r   a  
    *Read-only* representation of an attribute.

    .. warning::

       You should never instantiate this class yourself.

    The class has *all* arguments of `attr.ib` (except for ``factory`` which is
    only syntactic sugar for ``default=Factory(...)`` plus the following:

    - ``name`` (`str`): The name of the attribute.
    - ``alias`` (`str`): The __init__ parameter name of the attribute, after
      any explicit overrides and default private-attribute-name handling.
    - ``inherited`` (`bool`): Whether or not that attribute has been inherited
      from a base class.
    - ``eq_key`` and ``order_key`` (`typing.Callable` or `None`): The
      callables that are used for comparing and ordering objects by this
      attribute, respectively. These are set by passing a callable to
      `attr.ib`'s ``eq``, ``order``, or ``cmp`` arguments. See also
      :ref:`comparison customization <custom-comparison>`.

    Instances of this class are frequently used for introspection purposes
    like:

    - `fields` returns a tuple of them.
    - Validators get them passed as the first argument.
    - The :ref:`field transformer <transform-fields>` hook receives a list of
      them.
    - The ``alias`` property exposes the __init__ parameter name of the field,
      with any overrides and default private-attribute handling applied.


    .. versionadded:: 20.1.0 *inherited*
    .. versionadded:: 20.1.0 *on_setattr*
    .. versionchanged:: 20.2.0 *inherited* is not taken into account for
        equality checks and hashing anymore.
    .. versionadded:: 21.1.0 *eq_key* and *order_key*
    .. versionadded:: 22.2.0 *alias*

    For the full version history of the fields, see `attr.ib`.
    )r[   r,   r-   r.   r5   r6   r7   r8   r0   r1   r3   r*   r2   r4   r   r9   r:   NFc                 C  s   t ||p||p|d\}}}}t| }|d| |d| |d| |d| |d| |d| |d| |d	| |d
| |d| |d| |d|	rVtt|	nt |d|
 |d| |d| |d| |d| d S )NTr[   r,   r-   r.   r5   r6   r7   r8   r0   r1   r2   r3   r*   r4   r   r9   r:   )r;   r   r   typesMappingProxyTyper   _EMPTY_METADATA_SINGLETON)r   r[   r,   r-   r.   r/   r0   r1   r   r3   r*   r2   r4   r5   r6   r7   r8   r9   r:   bound_setattrr   r   r   r  C	  s4   















zAttribute.__init__c                 C  s   t r%   )r   r   r   r   r   r   z	  r   zAttribute.__setattr__c              	     sZ   |d u r j }n j d urd}t| fddtjD }| d| j j|d dd|S )Nz8Type annotation and type argument cannot both be presentc                   s    i | ]}|d vr|t  |qS ))r[   r-   r,   r*   r   r"  )r   r  r   r   r   r   	  s    
z0Attribute.from_counting_attr.<locals>.<dictcomp>F)r[   r-   r,   r*   r/   r   r   )r*   r=   r   r$  
_validator_default)r   r[   r   r*   rG   	inst_dictr   r$  r   r   }	  s$   

zAttribute.from_counting_attrc                 K  s   t  | }||  |S )a
  
        Copy *self* and apply *changes*.

        This works similarly to `attrs.evolve` but that function does not work
        with :class:`attrs.Attribute`.

        It is mainly meant to be used for `transform-fields`.

        .. versionadded:: 20.3.0
        )copy	_setattrsr   )r   r   newr   r   r   r   	  s   
zAttribute.evolvec                      t  fdd jD S )(
        Play nice with pickle.
        c                 3  s,    | ]}|d krt  |nt jV  qdS )r3   N)r   r   r3   r#  r   r   r   r   	  s
    
z)Attribute.__getstate__.<locals>.<genexpr>rB   r$  r   r   r   r   r   	  s   zAttribute.__getstate__c                 C  s   |  t| j| dS r,  N)r)  rR  r$  r   rS  r   r   r   r   	  s   zAttribute.__setstate__c                 C  sL   t | }|D ]\}}|dkr||| q|||r tt|nt qd S )Nr3   )r   r   r   r!  r   r"  )r   name_values_pairsr#  r[   r   r   r   r   r)  	  s   
zAttribute._setattrs)
NNNFNNNNNNr%   )r   r   r    r!   r$  r  r   r7  r   r   r   r   r)  r   r   r   r   r   	  s*    ,
7	r   c                 C  s2   g | ]}t |td dd dd|dkddt|dqS )NTFr3   )r[   r,   r-   r.   r/   r5   r7   r0   r1   r   r:   )r   r   r   r#  r   r   r   r   	  s     r   r  c                 C  s   g | ]	}|j d kr|qS r   r   r   r   r   r   r   	  s    c                 C  s    g | ]}|j r|jd kr|qS r   )r0   r[   r   r   r   r   r   	  s     c                   @  sn   e Zd ZdZdZg edd dD eddddddd	dd	ddd	dd	dd
R ZdZdd Z	dd Z
dd ZdS )rE   a  
    Intermediate representation of attributes that uses a counter to preserve
    the order in which the attributes have been defined.

    *Internal* data structure of the attrs library.  Running into is most
    likely the result of a bug like a forgotten `@attr.s` decorator.
    )r&  r%  r:   r2   r   r5   r6   r0   r1   r4   r3   r9   r7   r8   r.   r*   c                 c  s:    | ]}t |t|td dd ddddd dd dd dV  qd S )NTFr[   r:   r,   r-   r.   r/   r0   r1   r4   r5   r6   r7   r8   r   r9   )r   r   r   r#  r   r   r   r   
  s*    
z_CountingAttr.<genexpr>)	r   r&  r.   r5   r7   r0   r1   r9   r:   r3   NTFr1  r   c                 C  st   t  jd7  _t j| _|| _|| _|| _|| _|| _|| _|| _	|| _
|| _|| _|| _|	| _|
| _|| _|| _d S r   )rE   cls_counterr   r&  r%  r2   r.   r5   r6   r7   r8   r0   r1   r3   r*   r4   r9   r:   )r   r,   r-   r.   r/   r0   r1   r2   r3   r*   r4   r5   r6   r7   r8   r9   r:   r   r   r   r  5
  s"   
z_CountingAttr.__init__c                 C  s&   | j du r
|| _ |S t| j || _ |S )z
        Decorator that adds *meth* to the list of validators.

        Returns *meth* unchanged.

        .. versionadded:: 17.1.0
        N)r%  rD   r   rq  r   r   r   r-   Z
  s
   
z_CountingAttr.validatorc                 C  s    | j turtt|dd| _ |S )z
        Decorator that allows to set the default for an attribute.

        Returns *meth* unchanged.

        Raises:
            DefaultAlreadySetError: If default has been set before.

        .. versionadded:: 17.1.0
        T)r  )r&  r   r   r?   r3  r   r   r   r,   h
  s   
z_CountingAttr.default)r   r   r    r!   r$  rB   r   r   r2  r  r-   r,   r   r   r   r   rE   	  s<    1%rE   c                   @  s.   e Zd ZdZdZdddZdd Zdd	 Zd
S )r?   a  
    Stores a factory callable.

    If passed as the default value to `attrs.field`, the factory is used to
    generate a new value.

    Args:
        factory (typing.Callable):
            A callable that takes either none or exactly one mandatory
            positional argument depending on *takes_self*.

        takes_self (bool):
            Pass the partially initialized instance that is being initialized
            as a positional argument.

    .. versionadded:: 17.1.0  *takes_self*
    rF   r  Fc                 C  s   || _ || _d S r%   r4  )r   rF   r  r   r   r   r  
  s   
zFactory.__init__c                   r+  )r,  c                 3  s    | ]}t  |V  qd S r%   r"  r#  r   r   r   r   
      z'Factory.__getstate__.<locals>.<genexpr>r-  r   r   r   r   r   
  s   zFactory.__getstate__c                 C  s&   t | j|D ]
\}}t| || qdS r.  )rR  r$  r  )r   rS  r[   r   r   r   r   r   
  s   zFactory.__setstate__N)F)r   r   r    r!   r$  r  r   r   r   r   r   r   r?   ~
  s    
r?   c                 C  (   g | ]}t |td dd dddddd
qS NTF)
r[   r,   r-   r.   r/   r5   r7   r0   r1   r   r   r   r#  r   r   r   r   
      c                   @  sL   e Zd ZdZdZdddddZedd
dZdddZdd Z	dd Z
dS )r  ae  
    Stores a converter callable.

    Allows for the wrapped converter to take additional arguments. The
    arguments are passed in the order they are documented.

    Args:
        converter (Callable): A callable that converts the passed value.

        takes_self (bool):
            Pass the partially initialized instance that is being initialized
            as a positional argument. (default: `False`)

        takes_field (bool):
            Pass the field definition (an :class:`Attribute`) into the
            converter as a positional argument. (default: `False`)

    .. versionadded:: 24.1.0
    )__call__r  _global_namer2   takes_fieldr  Fr  r<  c                  s   | _ | _| _t|}|  _ js  js  fdd _n# jr. js. fdd _n js< jr< fdd _n fdd _| }|d urS| jjd< d S d S )Nc                   s
     | S r%   r2   )r   r  __r   r   r   r   
  r   z$Converter.__init__.<locals>.<lambda>c                   s     | |S r%   r>  )r   instancer?  r   r   r   r   
      c                   s     | |S r%   r>  )r   r?  rf  r   r   r   r   
  rA  c                   s     | ||S r%   r>  )r   r@  rf  r   r   r   r   
  s    r  )	r2   r  r<  r   get_first_param_typer  r:  get_return_typer  )r   r2   r  r<  exrtr   r   r   r  
  s    
zConverter.__init__rq   ry   r  c                 C  s
   d|  S )zh
        Return the name that a converter for an attribute name *attr_name*
        would have.
        __attr_converter_r   )rq   r   r   r   r  
  s   
zConverter._get_global_namer  c                 C  s   | j s| js| | d| dS | j r%| jr%| | d| d| dS | j r3| | d| dS | | d| d| dS )z
        Return a string that calls the converter for an attribute name
        *attr_name* and the value in variable named *value_var* according to
        `self.takes_self` and `self.takes_field`.
        r  r  z, self, attr_dict['z'])z, self)z, attr_dict[')r  r<  r  )r   rq   r  r   r   r   r  
  s   zConverter._fmt_converter_callc                 C  s   | j | j| jdS )zx
        Return a dict containing only converter and takes_self -- the rest gets
        computed when loading.
        r2   r  r<  rG  r   r   r   r   r   
  s   zConverter.__getstate__c                 C  s   | j di | dS )z+
        Load instance from state.
        Nr   r  r/  r   r   r   r     s   zConverter.__setstate__N)rq   ry   r  ry   )rq   ry   r  ry   r  ry   )r   r   r    r!   r$  r  r8  r  r  r   r   r   r   r   r   r  
  s    	
c                 C  r6  r7  r8  r#  r   r   r   r     r9  rG  c                   s^  t |tr|}nt |ttfrdd |D }nd}t||dd}|dd}|dd}	i  |dur: | |durB| d< |durJ| d< |	durR|	 d< t| |i  fdd	}
t	
tt td
jdd|
_W d   n1 szw   Y  |dd}t||d|dd\|d< |d< tdd|i||
}dd | D |_|S )a  
    A quick way to create a new class called *name* with *attrs*.

    .. note::

        ``make_class()`` is a thin wrapper around `attr.s`, not `attrs.define`
        which means that it doesn't come with some of the improved defaults.

        For example, if you want the same ``on_setattr`` behavior as in
        `attrs.define`, you have to pass the hooks yourself: ``make_class(...,
        on_setattr=setters.pipe(setters.convert, setters.validate)``

    Args:
        name (str): The name for the new class.

        attrs (list | dict):
            A list of names or a dictionary of mappings of names to `attr.ib`\
            s / `attrs.field`\ s.

            The order is deduced from the order of the names or attributes
            inside *attrs*.  Otherwise the order of the definition of the
            attributes is used.

        bases (tuple[type, ...]): Classes that the new class will subclass.

        class_body (dict):
            An optional dictionary of class attributes for the new class.

        attributes_arguments: Passed unmodified to `attr.s`.

    Returns:
        type: A new class with *attrs*.

    .. versionadded:: 17.1.0 *bases*
    .. versionchanged:: 18.1.0 If *attrs* is ordered, the order is retained.
    .. versionchanged:: 23.2.0 *class_body*
    c                 S  s   i | ]}|t  qS r   )rH   r   r   r   r   r   \  r  zmake_class.<locals>.<dictcomp>z(attrs argument must be a dict or a list.r   Nr   r  c                   s
   |   S r%   )r/  )rH  bodyr   r   r   o  r   zmake_class.<locals>.<lambda>r   r   __main__r/   r5   r7   Tr   c                 S  s"   i | ]\}}|j d ur||j qS r%   )r*   r  r   r   r   r     s    r   )r@   r   rA   rB   r<   popr/  r   	new_classr  r  r  r=   r  	_getframe	f_globalsr   r   r  r   r   r  )r[   rt   bases
class_bodyattributes_argumentscls_dictrG   r  r  	user_inittype_r/   r   r   rH  r   
make_class1  sN   
(
rU  )r  r  c                   @  s   e Zd ZdZe Zdd ZdS )_AndValidatorz2
    Compose many validators to a single one.
    c                 C  s   | j D ]}|||| qd S r%   )_validators)r   r   r   r   r  r   r   r   r:    s   
z_AndValidator.__call__N)r   r   r    r!   rH   rW  r:  r   r   r   r   rV    s    rV  c                  G  s6   g }| D ]}| t|tr|jn|g qtt|S )a  
    A validator that composes multiple validators into one.

    When called on a value, it runs all wrapped validators.

    Args:
        validators (~collections.abc.Iterable[typing.Callable]):
            Arbitrary number of validators.

    .. versionadded:: 17.1.0
    )r   r@   rV  rW  rB   )
validatorsr  r-   r   r   r   rD     s   rD   c                    s   t dd  D }|r fdd}n fdd} s)td}|j||d n*t d  }|r8||jd	<  d
 }tsFt|t	rF|j
}t| }|rS||jd< |r\t	|dddS |S )a  
    A converter that composes multiple converters into one.

    When called on a value, it runs all wrapped converters, returning the
    *last* value.

    Type annotations will be inferred from the wrapped converters', if they
    have any.

        converters (~collections.abc.Iterable[typing.Callable]):
            Arbitrary number of converters.

    .. versionadded:: 20.1.0
    c                 s  s    | ]}t |tV  qd S r%   r@   r  )r   cr   r   r   r     r5  zpipe.<locals>.<genexpr>c                   s,    D ]}t |tr|| ||n|| } q| S r%   rY  )ry  r   rf  rZ  
convertersr   r   pipe_converter  s   zpipe.<locals>.pipe_converterc                   s    D ]}|| } q| S r%   r   )ry  rZ  r[  r   r   r]    s   
A)ry  r  r   ry  rS   r  Tr=  )r  typingTypeVarr  r/  r   rB  r	   r@   r  r:  rC  )r\  return_instancer]  r^  tlastrE  r   r[  r   rC     s&   



rC   )NrI   r%   )T)NNNNNNNFFTFFFFFNNFFNNNTN)NNr  r  )rq   ry   r   ry   r  r   r  ry   )r  r   r  r   r   r  )rt   r  r  r   r  r   r   r   r  r   r  r   r  r   r   r  r  r   r  r   r  r   r  ry   r  r  )r[   ry   r  ry   )c
__future__r   r  r  r(  r"   r%  r   r4  rX   r  r   r_  operatorr   rI   r   r   r   r   r	   r
   r   r   r   
exceptionsr   r   r   r   objectr   r   r  r|   r3  r!  r"  r  rC   r   r   r   Enumr   r   intr$   rH   rR   ra   rr   rs   r~   r   r   r   r   r   r   r   r   r   r  r;   r  rt   r   r  r   r[  r  rn  rm  rv  r  rG  r  r   r  r  ra  r  r  r  r  r  r  r   r   r$  _arE   r?   _fr  rU  rV  rD   r   r   r   r   <module>   s2   		


k
	m::    ,

 a
G&
8
9.
O





/  
 L
	 'd

a