a
    &ñ»j‘ž ã                   @  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mZ d dlmZ d dlmZmZ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j0¡Z1G dd„ dej2ƒZ3e3j4Z4G dd„ de5ƒZ6e4ddddddddddddddfdd„Z7džddddddœdd„Z8dŸddddddœdd„Z9dd d!d"œd#d$„Z:G d%d&„ d&eƒZ;d'd(„ Z<d)d*„ Z=d+d,œd-d.„Z>d/d0„ Z?d&d,œd1d2„Z@d3d4„ ZAd5d6„ ZBd7d8„ ZCd9d:„ ZDG d;d<„ d<ƒZEd=d>„ ZFd?d@„ ZGd dAdB„ZHd¡dDdE„ZIeIZJdFdG„ ZKd!dddHœdIdJ„ZLd!dKdLdLdMdNœdOdP„ZMd!dKdQœdRdS„ZNdTdU„ ZOdVdMdWœdXdY„ZPdZd[„ ZQd¢d\d]„ZRdMd,œd^d_„ZSd£d`da„ZTdbdc„ ZUddde„ ZVdfdg„ Z0dhdi„ ZWdjd,œdkdl„ZXdddLddmœdndo„ZYdddLdpddqœdrds„ZZdddLddtœdudv„Z[dddLdpddqœdwdx„Z\dLdLdydzœd{d|„Z]dKdLdLdLdLdLdLdydLdLdLddjd}œd~d„Z^ddd€œd�d‚„Z_G dƒd„„ d„ƒZ`d…d†„ e`jaD ƒZbeNeReTe`ebd‡�dˆd†„ ebD ƒd‡�d‰d†„ ebD ƒd‡�Z`G dŠd‹„ d‹ƒZceReTecƒƒZcG dŒd�„ d�ƒZddŽd†„ edjaD ƒZeeReTedeed‡�eed‡�ZdG d�d�„ d�ƒZfd‘d†„ efjaD ƒZgeNeReTefegd‡�egd‡�egd‡�ZfG d’dp„ dpƒZhd“d†„ d”D ƒZgeNeReTehegd‡�egd‡�egd‡�Zhe%fdfd•d–„ZieIddd—�G d˜d™„ d™ƒƒZjdšd›„ Zkdœd�„ Z.dS )¤é    )ÚannotationsN)ÚCallableÚMapping)Úcached_property)ÚAnyÚ
NamedTupleÚTypeVaré   )Ú_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.ClassVarZ_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  s   dS )NÚNOTHING© ©Úselfr   r   ú0E:\soccer\ml_env\Lib\site-packages\attr/_make.pyÚ__repr__K   s    z_Nothing.__repr__c                 C  s   dS )NFr   r   r   r   r   Ú__bool__N   s    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   Z_none_constructorÚ_argsr   r   r   Ú
__reduce__f   s    z_CacheHashWrapper.__reduce__)r    r!   r"   r#   Útyper)   r   r   r   r   r&   Z   s   r&   Tc                 C  sò   t |||dƒ\}}}}|dur:|dur:|dur:d}t|ƒ‚|	durr| turVd}t|ƒ‚t|	ƒsjd}t|ƒ‚t|	ƒ} |du r~i }t|ttfƒr–t	j
|Ž }|r°t|ttfƒr°t|Ž }|rÊt|ttfƒrÊt
|Ž }t| ||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*
    .. versionchanged:: 25.4.0
       *kw_only* can now be None, and its default is also changed from False to
       None.
    TNFú6Invalid 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Úalias)Ú_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   Úattribj   sR    :ÿÿ
ðrH   Ú Ústrzdict[str, Any] | NonezMapping[str, object] | NoneÚNone)ÚscriptÚglobsÚlocsÚfilenameÚreturnc                 C  s   t | |dƒ}t|||ƒ dS )z[
    Evaluate the script with the given global (globs) and local (locs)
    variables.
    ÚexecN)ÚcompileÚeval)rL   rM   rN   rO   Úbytecoder   r   r   Ú_compile_and_evalØ   s    
rU   zdict[str, Any])rL   rO   rM   ÚlocalsrP   c           	      C  sz   |du ri n|}d}|}t | ƒd|  d¡|f}tj ||¡}||krFqh|dd… › d|› d�}|d7 }qt| |||ƒ |S )zP
    Cache the script with _linecache_, compile it and return the _locals_.
    Nr	   Téÿÿÿÿú-ú>)ÚlenÚ
splitlinesÚ	linecacheÚcacheÚ
setdefaultrU   )	rL   rO   rM   rV   rN   ÚcountÚbase_filenameZlinecache_tupleZold_valr   r   r   Ú_linecache_and_compileæ   s    
ü
ra   z	list[str]r*   )Úcls_nameÚ
attr_namesrP   c                 C  sF   | › d�}i }t |ƒD ] \}}|fdd„}t|ƒ||< qt|tf|ƒ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))
    Z
Attributesc                 S  s   | | S r'   r   )r   Úir   r   r   Úgetter  s    z&_make_attr_tuple_class.<locals>.getter)Ú	enumerateÚpropertyr*   rB   )rb   rc   Zattr_class_nameÚbodyrd   Ú	attr_namere   r   r   r   Ú_make_attr_tuple_class	  s    

rj   c                   @  s&   e Zd ZU ded< ded< ded< dS )Ú_Attributesr*   Úattrsúlist[Attribute]Ú
base_attrsúdict[str, type]Zbase_attrs_mapN)r    r!   r"   Ú__annotations__r   r   r   r   rk      s   
rk   c                 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	   rW   )rJ   Ú
startswithÚendswithÚ_CLASSVAR_PREFIXES)Zannotr   r   r   Ú_is_class_var&  s    rv   c                 C  s
   || j v S )zR
    Check whether *cls* defines *attrib_name* (and doesn't just inherit it).
    )Ú__dict__)ÚclsZattrib_namer   r   r   Ú_has_own_attribute7  s    ry   z'tuple[list[Attribute], dict[str, type]]©rP   c                 C  s¨   g }i }t | jdd… ƒD ]H}t|dg ƒD ]6}|js*|j|v r@q*|jdd�}| |¡ |||j< q*qg }tƒ }t |ƒD ](}|j|v r†qv| d|¡ | 	|j¡ qv||fS )zQ
    Collect attr.ibs from base classes of *cls*, except *taken_attr_names*.
    r	   rW   Ú__attrs_attrs__T©Ú	inheritedr   )
ÚreversedÚ__mro__Úgetattrr}   ÚnameÚevolveÚappendÚsetÚinsertÚadd)rx   Útaken_attr_namesrn   Úbase_attr_mapÚbase_clsÚaÚfilteredÚseenr   r   r   Ú_collect_base_attrs>  s"    

r�   c                 C  sn   g }i }| j dd… D ]N}t|dg ƒD ]<}|j|v r6q&|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	   rW   r{   Tr|   )r   r€   r�   r‚   r†   rƒ   )rx   r‡   rn   rˆ   r‰   rŠ   r   r   r   Ú_collect_base_attrs_broken_  s    

rŽ   c              	     sŽ  | j ‰t| ƒ‰ |dur$t| ¡ ƒ}nÈ|du rÎdd„ ˆ ¡ D ƒ}g }tƒ }ˆ  ¡ D ]H\}	}
t|
ƒrbqP| |	¡ ˆ |	t¡}|j	t
urŠt|ƒ}| |	|f¡ qP|| }|rìtdd t|‡fdd„d	�¡ d
 ƒ‚ntdd„ ˆ ¡ D ƒdd„ d	�}tj‰tjj‰‡ ‡‡‡fdd„|D ƒ}|�r2t| dd„ |D ƒƒ\}}nt| dd„ |D ƒƒ\}}ˆtjju �rtdd„ |D ƒ}dd„ |D ƒ}|| }|D ]4}|j�s€t |¡dt|jƒƒ t |¡ddƒ �q€|du�rÎt|| |ƒƒ}d}dd„ |D ƒD ]H}|du �r|jtu �rd|›�}t|ƒ‚|du �rà|jtu�ràd}�qà|D ]4}|j�s.t |¡dt|jƒƒ t |¡ddƒ �q.dd„ |D ƒ}t | j!|ƒ}t"||ƒ||ƒ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 | ]\}}|j tu r|’qS r   ©Ú	__class__rE   ©Ú.0r�   Úattrr   r   r   Ú	<setcomp>“  s   
þz#_transform_attrs.<locals>.<setcomp>z1The following `attr.ib`s lack a type annotation: ú, c                   s   ˆ   | ¡jS r'   )ÚgetÚcounter)Ún)Úcdr   r   Ú<lambda>©  ó    z"_transform_attrs.<locals>.<lambda>)ÚkeyÚ.c                 s  s$   | ]\}}|j tu 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š   ´  r›   c              	     s(   g | ] \}}ˆ||ˆˆuˆ   |¡ƒ‘qS r   )r–   )r’   ri   Úca)ÚannsÚfcar4   Únor   r   Ú
<listcomp>¹  s   úüz$_transform_attrs.<locals>.<listcomp>c                 S  s   h | ]
}|j ’qS r   ©r�   ©r’   rŠ   r   r   r   r”   Å  r›   c                 S  s   h | ]
}|j ’qS r   r¦   r§   r   r   r   r”   É  r›   c                 S  s   g | ]}|j d d�‘qS ©T)r4   ©r‚   r§   r   r   r   r¥   Í  r›   c                 S  s   g | ]}|j d d�‘qS r¨   r©   r§   r   r   r   r¥   Î  r›   r:   Úalias_is_defaultFc                 s  s&   | ]}|j d ur|jd u r|V  qdS )FN)r1   r4   r§   r   r   r   rž   ä  r›   zlNo mandatory attributes allowed after an attribute with a default value or factory.  Attribute in question: c                 S  s   g | ]
}|j ‘qS r   r¦   r§   r   r   r   r¥   õ  r›   )#rw   r   rA   Úitemsr„   rv   r†   r–   r   r�   rE   rH   rƒ   r   ÚjoinÚsortedÚ	AttributeÚfrom_counting_attrÚ
ClassPropsÚKeywordOnlyÚNOr�   rŽ   ÚFORCEr:   Ú_OBJ_SETATTRÚ__get__Ú_default_init_alias_forr�   rB   r,   r=   rj   r    rk   )rx   ÚtheseÚauto_attribsr4   Úcollect_by_mroÚfield_transformerZca_listZca_namesZannot_namesri   r*   rŠ   ZunannotatedZ	own_attrsrn   rˆ   rl   Zhad_defaultrG   rc   Z
AttrsClassr   )r¢   r™   r£   r4   r¤   r   Ú_transform_attrs{  sŽ    þ

ÿÿüÿþú	ù
ÿ
ÿ

r»   c                 C  sn   g d¢}|d ur|  d¡ n| g d¢¡ | ddg¡ t|dƒ}| tj|dœ}td |¡||d	|id
�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Ú
Ú_cls)rV   Ú__getattr__)rƒ   ÚextendÚ_generate_unique_filenamer´   rµ   ra   r¬   )r¼   r¾   rx   ÚlinesZunique_filenameÚglobr   r   r   Ú_make_cached_property_getattrû  s.    ÿÿþÿ
ýÿþrÆ   c                 C  s,   t | tƒr$|dv r$t | ||¡ dS t‚dS )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kr"t | |¡ dS t‚dS )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 y6   dt| ƒ› d�}t|ƒd‚Y n0 |j}t|ƒ}|D ].}|jsVqJ|j}|j}||vrJt||ƒ||< qJ|f 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 givenN)	r=   rZ   r<   r�   Úfieldsr1   r�   r:   r€   )	ÚargsÚchangesÚinstrG   rx   rl   rŠ   ri   Z	init_namer   r   r   r‚   K  s     %
ÿr‚   c                   @  sÖ   e Zd ZdZdZdddddœdd„Zd	d
„ Zddœ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-d.œd/d0„Zd-d-d.œd1d2„Zd3S )4Ú_ClassBuilderz(
    Iteratively build *one* class.
    )Ú_add_method_dundersÚ_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Ú_repr_addedÚ_script_snippetsÚ_slotsÚ_weakref_slotÚ_wrote_own_setattrr*   Úboolr°   )rx   r¸   ÚpropsÚhas_custom_setattrc                 C  sD  t ||||j|j|jƒ\}}}|| _|jr4t|jƒni | _|| _	dd„ |D ƒ| _
|| _tdd„ |D ƒƒ| _|j| _|j| _|j| _|jtjju | _tt|ddƒƒ| _d| _| jrÐ|j}	t |	¡}
t|
j ƒdk| _tt|ddƒƒ| _!t|ƒ | _"|j#| _$|j%| _&|| _'d| _(| j	| jd	< || jd
< |j�rDt)| jd< t*| jd< d| _(n¢| j&t+t,j-t,j.fv �ræd }}|D ]8}|j/d u�rzd}|j0d u�rŠd}|�rf|�rf �q �qf| j&t+k�r¸|�s¸|�rà| j&t,j-k�rÌ|�rà| j&t,j.k�ræ|�sæd | _&|j1�r|  2¡ \| jd< | jd< g | _3d| _4t5| jdƒ�r.t5| jdƒ�s8| j6| _7n| j8| _7d S )Nc                 S  s   h | ]
}|j ’qS 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ž   ¸  r›   z)_ClassBuilder.__init__.<locals>.<genexpr>Ú__attrs_pre_init__Fr	   Ú__attrs_post_init__r{   Z__attrs_props__rÍ   rÑ   TÚ__getstate__Ú__setstate__r!   r"   )9r»   r4   Úcollected_fields_by_mrorº   rÀ   Ú
is_slottedÚdictrw   rÞ   rÚ   rÜ   rÛ   rB   rÙ   ré   Ú	is_frozenrà   Úhas_weakref_slotrê   Úhashabilityr°   ÚHashabilityÚHASHABLE_CACHEDrÝ   rì   r€   rã   ræ   rï   ÚinspectÚ	signaturerZ   Ú
parametersrâ   rß   Úis_exceptionrä   Úon_setattr_hookrå   rá   rë   rÐ   rÒ   Ú_DEFAULT_ON_SETATTRr   ÚvalidateÚconvertr-   r2   Úadded_picklingÚ_make_getstate_setstaterè   rç   ÚhasattrÚ_add_method_dunders_saferØ   Ú_add_method_dunders_unsafe)r   rx   r·   r¸   rí   rî   rl   rn   Zbase_mapZpre_init_funcZpre_init_signatureZhas_validatorZ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__rK   rz   c                 C  sl   d  dd„ | jD ƒ¡}i }| jD ]\}}}| |¡ q t|t| jdƒ|ƒ}| jD ]\}}}|| j|ƒ qPdS )z=
        Evaluate any registered snippets in one go.
        r¿   c                 S  s   g | ]}|d  ‘qS )r   r   )r’   Zsnippetr   r   r   r¥     r›   z0_ClassBuilder._eval_snippets.<locals>.<listcomp>ÚmethodsN)r¬   rè   Úupdatera   rÃ   rÀ   rÞ   )r   rL   rM   Ú_Zsnippet_globsrN   Úhookr   r   r   Ú_eval_snippets
  s    
ýz_ClassBuilder._eval_snippetsc                 C  sb   |   ¡  | jdu r*|  ¡ }t |¡| j_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  ré   Ú_create_slots_classÚweakrefÚrefrÀ   Z__attrs_base_of_slotted__Ú_patch_original_classr   ÚabcZupdate_abstractmethodsr€   rw   r  )r   rx   r   r   r   Úbuild_class  s    


ÿþz_ClassBuilder.build_classc              	   C  s²   | j }| j}| jrj| jD ]P}||vrt||tƒturt t¡� t	||ƒ W d  ƒ q1 s^0    Y  q| j
 ¡ D ]\}}t|||ƒ qt| js®t|ddƒr®d|_| js®t|_|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   rx   Ú
base_namesr�   rÏ   r   r   r   r  5  s&    
ÿþ*ÿz#_ClassBuilder._patch_original_classc              
     sÖ  ‡fdd„ˆj  ¡ D ƒ}ttdƒr.t ˆj¡ ˆjsjd|d< ˆjsjˆjjD ]‰ ˆ j	 
dd¡rJt|d<  qjqJi }d}ˆjjdd… D ]:‰ ˆ j	 
d	d
¡d
urœd}| ‡ fdd„tˆ dg ƒD ƒ¡ q‚tˆjƒ‰ˆj}ˆjrúd	tˆjddƒvrúd	|vrú|sú|d7 }dd„ | ¡ D ƒ}g }|�r tˆjƒ}| ¡ D ]F\}}	||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 ]–}t$|t%t&fƒ�r^t|j'dd
ƒ}n(t$|t(ƒ�rzt|j)dd
ƒ}nt|dd
ƒ}|�s��q:|D ]8}z|j*ˆju }W n t+�y¼   Y n0 |�r”||_*�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 )rw   Ú__weakref__)rB   rÙ   ©r’   ÚkÚvr   r   r   Ú
<dictcomp>]  s   þz5_ClassBuilder._create_slots_class.<locals>.<dictcomp>Ú_clear_type_descriptorsFr  rÍ   r	   rW   r  NTc                   s   i | ]}|t ˆ |ƒ“qS r   ©r€   ©r’   r�   )r‰   r   r   r!  €  s   ÿÚ	__slots__r   )r  c                 S  s"   i | ]\}}t |tƒr||j“qS r   )r@   r   Úfunc)r’   r�   Zcached_propr   r   r   r!  ‘  s   
þrÁ   c                   s   g | ]}|ˆ vr|‘qS r   r   r$  )r  r   r   r¥   °  r›   z5_ClassBuilder._create_slots_class.<locals>.<listcomp>c                   s   i | ]\}}|ˆ v r||“qS r   r   )r’   ZslotZslot_descriptor)Ú
slot_namesr   r   r!  ¶  s   þc                   s   g | ]}|ˆ vr|‘qS r   r   r$  )Úreused_slotsr   r   r¥   »  r›   r"   Ú__closure__),rÞ   r«   r  Úsysr"  rÀ   rë   rá   Ú	__bases__rw   r–   r´   r   r
  r€   r„   rÜ   rÙ   rê   r   rƒ   rû   rü   Úreturn_annotationÚ	ParameterÚemptyrÆ   rÝ   Ú_HASH_CACHE_FIELDrB   r"   r*   r    Ú	itertoolsÚchainÚvaluesr@   ÚclassmethodÚstaticmethodÚ__func__rg   ÚfgetÚcell_contentsr=   )r   r™   Zexisting_slotsZweakref_inheritedÚnamesr¼   Z&additional_closure_functions_to_updateZclass_annotationsr�   r&  Ú
annotationr¾   rx   ÚitemZclosure_cellsÚcellÚmatchr   )r‰   r  r(  r   r'  r   r  Y  s¢    
þ



þÿ
ÿþýüþ





ÿ
þ


ÿz!_ClassBuilder._create_slots_classc                   s8   t ˆ j|ƒ\}}‡ fdd„}ˆ j |||f¡ dˆ _ˆ S )Nc                   s   ˆ   |d ¡| d< d S )Nr   ©rØ   ©Úcls_dictrM   r   r   r   Ú_attach_reprë  s    z,_ClassBuilder.add_repr.<locals>._attach_reprT)Ú_make_repr_scriptrÚ   rè   rƒ   rç   )r   ÚnsrL   rM   r@  r   r   r   Úadd_reprè  s
    z_ClassBuilder.add_reprc                 C  s.   | j sd}t|ƒ‚dd„ }|  |¡| jd< | S )Nz3__str__ can only be generated if a __repr__ exists.c                 S  s   |   ¡ S r'   ©r   r   r   r   r   Ú__str__÷  s    z&_ClassBuilder.add_str.<locals>.__str__rE  )rç   r=   rØ   rÞ   )r   rG   rE  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’   Z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                   s   i | ]}|t ˆ |ƒ“qS 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  s    z=_ClassBuilder._make_getstate_setstate.<locals>.slots_getstatec                   sf   t  | ¡}t|tƒr4tˆ|ƒD ]\}}|||ƒ qn ˆD ]}||v r8|||| ƒ q8ˆ rb|tdƒ dS )rG  N)r´   rµ   r@   rB   Úzipr/  )r   ÚstateZ_ClassBuilder__bound_setattrr�   rÏ   ©Zhash_caching_enabledrH  r   r   Úslots_setstate  s    

z=_ClassBuilder._make_getstate_setstate.<locals>.slots_setstate)rB   rÙ   rÝ   )r   rI  rM  r   rL  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                   sH   t ˆ jˆ jˆ jˆ jd�\}}ddddœ‡ fdd„}ˆ j |||f¡ ˆ S )N©ÚfrozenÚ
cache_hashrõ   rK   )r?  rN   rP   c                   s   ˆ   |d ¡| d< d S rN  r=  )r?  rN   r   r   r   Úattach_hash2  s    z+_ClassBuilder.add_hash.<locals>.attach_hash)Ú_make_hash_scriptrÀ   rÚ   rà   rÝ   rè   rƒ   )r   rL   rM   rT  r   r   r   Úadd_hash*  s    ü
z_ClassBuilder.add_hashc                   s`   t ˆjˆjˆjˆjˆjˆjˆjˆjˆj	ˆj
ˆjdd�\}}‰ ‡ ‡fdd„}ˆj |||f¡ ˆS )NF©Ú
attrs_initc                   s    |d }ˆ |_ ˆ |¡| d< d S )Nr  ©rp   rØ   ©r?  rM   r1   ©r   r   r   r   Ú_attach_initI  s    z,_ClassBuilder.add_init.<locals>._attach_init©Ú_make_init_scriptrÀ   rÚ   rã   ræ   râ   rà   ré   rÝ   rÛ   rä   rå   rè   rƒ   )r   rL   rM   r\  r   r[  r   Úadd_init9  s"    ôz_ClassBuilder.add_initc                 C  s   |   t¡| jd< | S )NÚ__replace__)rØ   r‚   rÞ   r   r   r   r   Úadd_replaceR  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ž   W  s   þz/_ClassBuilder.add_match_args.<locals>.<genexpr>Ú__match_args__)rB   rÚ   rÞ   r   r   r   r   Úadd_match_argsV  s    þz_ClassBuilder.add_match_argsc                   s`   t ˆjˆjˆjˆjˆjˆjˆjˆjˆj	ˆj
ˆjdd�\}}‰ ‡ ‡fdd„}ˆj |||f¡ ˆS )NTrW  c                   s    |d }ˆ |_ ˆ |¡| d< d S )NÚ__attrs_init__rY  rZ  r[  r   r   Ú_attach_attrs_initm  s    z8_ClassBuilder.add_attrs_init.<locals>._attach_attrs_initr]  )r   rL   rM   rf  r   r[  r   Úadd_attrs_init]  s"    ôz_ClassBuilder.add_attrs_initc                   s>   ˆ j }tˆ jƒ\}}‡ fdd„}ˆ j |||f¡ t|d< ˆ S )Nc                   s   ˆ   |d ¡| d< d S )NÚ__eq__r=  r>  r   r   r   Ú
_attach_eq{  s    z(_ClassBuilder.add_eq.<locals>._attach_eqÚ__ne__)rÞ   Ú_make_eq_scriptrÚ   rè   rƒ   rj  )r   r™   rL   rM   ri  r   r   r   Úadd_eqv  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'   r=  )r’   Úmethr   r   r   rž   ‡  s   ÿz*_ClassBuilder.add_order.<locals>.<genexpr>Ú__lt__Ú__le__Ú__gt__Ú__ge__)rÞ   Ú_make_orderrÀ   rÚ   )r   r™   r   r   r   Ú	add_order„  s
    
þz_ClassBuilder.add_orderc                   s‚   i ‰ | j D ],}|jp| j}|r
|tjur
||fˆ |j< q
ˆ s@| S | jrRd}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0 || ||ƒ}t| ||ƒ d S r'   )ÚKeyErrorr´   )r   r�   ÚvalrŠ   r  Znval©Zsa_attrsr   r   rÍ   ž  s    
z._ClassBuilder.add_setattr.<locals>.__setattr__Tr  rÍ   )rÚ   r9   rå   r   ÚNO_OPr�   rá   r=   rÞ   rØ   rë   )r   rŠ   r9   rG   rÍ   r   rv  r   Úadd_setattrŽ  s    


z_ClassBuilder.add_setattrr   )ÚmethodrP   c                 C  s6   | j j|_| j j› d|j› �|_d| j j› d�|_|S )z@
        Add __module__ and __qualname__ to a *method*.
        r�   ú$Method generated by attrs for class )rÀ   r!   r"   r    r#   ©r   ry  r   r   r   r  ®  s
    
ÿz(_ClassBuilder._add_method_dunders_unsafec                 C  s´   t  t¡� | jj|_W d  ƒ n1 s*0    Y  t  t¡�& | jj› d|j› �|_W d  ƒ n1 sj0    Y  t  t¡�" d| jj› d�|_W d  ƒ n1 s¦0    Y  |S )zL
        Add __module__ and __qualname__ to a *method* if possible.
        Nr�   rz  )r  r  r  rÀ   r!   r"   r    r#   r{  r   r   r   r  ¼  s    (40z&_ClassBuilder._add_method_dunders_safeN)r    r!   r"   r#   r%  r  r   r  r  r  r  rC  rF  r  rP  rV  r_  ra  rd  rg  rl  rs  rx  r  r  r   r   r   r   r×   …  s.   e$ 
)
 r×   c                 C  st   | dur(t |du|dufƒr(d}t|ƒ‚| dur8| | fS |du rD|}|du rP|}|du rl|du rld}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rP|| ƒ\} }| || |fS |du rd|d }}n||ƒ\}}|du r„|| }}n||ƒ\}}|du r¬|du r¬d}t|ƒ‚||||fS )r|  Nr}  c                 S  s    t | ƒrd|  } }n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ƒ  Z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)ry   )rx   ÚflagÚauto_detectZdundersr,   Údunderr   r   r   Ú_determine_whether_to_implement  s    
r‡  Fc                   s¢   ˆdur"ddl }|jtdƒdd� t|||dƒ\‰‰|dur@|‰
tˆttfƒrXtjˆŽ ‰‡ ‡‡‡‡‡‡‡‡‡	‡
‡‡‡‡‡‡‡‡‡‡‡fdd„}| du rš|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*.
    .. versionchanged:: 25.4.0
       *kw_only* now only applies to attributes defined in the current class,
       and respects attribute-level ``kw_only=False`` settings.
    .. versionadded:: 25.4.0 *force_kw_only*
    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|ƒ‚| oRt| ˆˆdƒ}tj}|rf|j}n’ˆ
du r€ˆrx|j	n|j
}nxˆ
du r�|j}nhˆ
d u rìˆdu r²t| dƒr²|j}qø|du rÔ|du rÔˆrÌ|j	n|j
}qø|du rä|j}qø|j}nd}t|ƒ‚tj}ˆ�rˆ�r|jn|j}	n|j}	t||ˆˆt| ˆˆdƒt| ˆˆd	ƒ|| �oVt| ˆˆd
ƒ|ˆ|	ˆˆt| ˆ	ˆdˆd�ˆˆd�}
|
j�s”ˆ�r”d}t|ƒ‚t| ˆˆ |
|d�}|
j�r¸| ˆ¡ |
j�rÈ| ¡  |
j�rØ| ¡  |
j�rè| ¡  ˆ�sö| ¡  |
j�r| ¡  n|
j|ju �r| ¡  |
j�r0|  ¡  n| !¡  ˆ�rJd}t|ƒ‚t"�rdt| dƒ�sd| #¡  t$�r„ˆ�r„t| dƒ�s„| %¡  | &¡ S )NTrÍ   z/Can't freeze a class with a custom __setattr__.)rh  rj  FrO  r+   ©r  rD  )rn  ro  rp  rq  )rñ   rò   )r,   )rþ   rö   rô   ró   Ú
added_initÚ
added_reprÚadded_eqÚadded_orderingrø   Úadded_match_argsr4   r÷   Ú	added_strr  rÿ   rº   zlInvalid value for cache_hash.  To use hash caching, hashing must be either explicitly or implicitly enabled.)r¸   rí   rî   zFInvalid value for cache_hash.  To use hash caching, init must be True.r`  rc  )'Ú_has_frozen_base_classÚ
issubclassrÌ   ry   r=   r‡  r°   rù   ÚLEAVE_ALONErú   ÚHASHABLEÚ
UNHASHABLEr<   r±   r³   ÚYESr²   Úis_hashabler×   rŒ  rC  r�  rF  r�  rl  rŽ  rs  rx  rV  rø   rP  r‹  r_  rg  r   ra  r   rd  r  )rx   rö   Úis_excZhas_own_setattrrG   r5   rù   rø   r±   Zkworí   Úbuilder©r¸   r…  Úauto_excrS  r¹   Zeq_rº   Úforce_kw_onlyrR  Úgetstate_setstater0   r1   r4   Ú
match_argsr9   Zorder_r.   Úrepr_nsÚslotsrJ   r·   Úweakref_slotr   r   Úwrap¡  sà    ÿÿÿýÿýÿÿüûà#û


ÿþýzattrs.<locals>.wrap)	ÚwarningsÚwarnÚDeprecationWarningr‚  r@   rA   rB   r   rC   )Z	maybe_clsr·   rŸ  r.   r/   r0   r1   r   rR  r¡  rJ   r¸   r4   rS  r›  r5   r7   r…  r¹   r�  r9   rº   rž  Úunsafe_hashrœ  r£  r¢  r   rš  r   rl   -  s$    aÿü
6 rl   c                 C  s
   | j tu S )zV
    Check whether *cls* has a frozen ancestor by looking at its
    __setattr__.
    )rÍ   rÐ   )rx   r   r   r   r‘  9  s    r‘  )rx   Ú	func_namerP   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"   rY   )r!   r€   r    )rx   r§  r   r   r   rÃ   A  s    ÿÿrÃ   rm   rì   ztuple[str, dict])rx   rl   rR  rS  rP   c                   s  t dd„ ˆ D ƒƒ‰ d}tt| dƒƒ‰i ‰d}d‰d‰|sB|d7 }n |d	7 }|d
7 }dˆ ‰ˆd7 ‰|g‰‡ ‡‡‡‡‡fdd„}|ròˆ |dt› d� ¡ |rÆ|dt› d�|d ƒ ˆ |d d ¡ n|dt› d�|d ƒ ˆ |dt› � ¡ n
|d|ƒ d ˆ¡}|ˆfS )Nc                 s  s0   | ](}|j d u s$|j du r|jd u r|V  qdS )TN)r0   r5   r§   r   r   r   rž   N  s   z$_make_hash_script.<locals>.<genexpr>ú        r0   zdef __hash__(selfzhash((z))z):z, *zC, _cache_wrapper=__import__('attr._make')._make._CacheHashWrapper):z_cache_wrapper(ú)c              	     s˜   ˆ  ||  ˆ |dˆ› d� g¡ ˆ D ]Z}|jrhd|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©  ú,r  Ú_keyú(self.z),ú        self.ú    N)rÂ   r6   r�   rƒ   )ÚprefixÚindentrŠ   Úcmp_name©rl   Zclosing_bracesrM   Z	hash_funcZmethod_linesZ	type_hashr   r   Úappend_hash_computation_linesf  s    
þÿ
ÿz8_make_hash_script.<locals>.append_hash_computation_lineszif self.z	 is None:zobject.__setattr__(self, 'ú', rˆ  úself.ú = zreturn self.zreturn r¿   )rB   r0   rÃ   rƒ   r/  r¬   )rx   rl   rR  rS  ÚtabZhash_defr´  rL   r   r³  r   rU  K  s>    ÿ
ÿÿ

rU  )rx   rl   c                 C  s6   t | |ddd�\}}t||t| dƒd� |d | _| S )z%
    Add a hash method to *cls*.
    FrQ  rO  ©rO   )rU  rU   rÃ   rO  ©rx   rl   rL   rM   r   r   r   Ú	_add_hash“  s    ÿ
ÿ
r»  c                 C  s   |   |¡}|tu rtS | S )z^
    Check equality and either forward a NotImplemented or
    return the result negated.
    )rh  ÚNotImplemented)r   ÚotherÚresultr   r   r   rj  ¡  s    
rj  rA   )rl   rP   c                 C  sÚ   dd„ | D ƒ} g d¢}i }| r¾|  d¡ | D ]„}|jrxd|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 |¡}||fS )z6
    Create __eq__ method for *cls* with *attrs*.
    c                 S  s   g | ]}|j r|‘qS r   )r5   r§   r   r   r   r¥   ±  r›   z#_make_eq_script.<locals>.<listcomp>)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.rW   z andz    )z    return Truer¿   )rƒ   r6   r�   r¬   )rl   rÄ   rM   rŠ   r²  rL   r   r   r   rk  ­  s&    

 ÿ

rk  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  s   g | ]}|j r|‘qS r   )r7   r§   r   r   r   r¥   Ö  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ž   Ü  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ž   Þ  s   )rB   r¿  ©rl   r¿  r   Úattrs_to_tupleØ  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   rn  ã  s    z_make_order.<locals>.__lt__c                   s    |j | j u rˆ | ƒˆ |ƒkS tS rÃ  rÄ  rÅ  rÆ  r   r   ro  ì  s    z_make_order.<locals>.__le__c                   s    |j | j u rˆ | ƒˆ |ƒkS tS rÃ  rÄ  rÅ  rÆ  r   r   rp  õ  s    z_make_order.<locals>.__gt__c                   s    |j | j u rˆ | ƒˆ |ƒkS tS rÃ  rÄ  rÅ  rÆ  r   r   rq  þ  s    z_make_order.<locals>.__ge__r   )rx   rl   rn  ro  rp  rq  r   )rl   rÂ  r   rr  Ò  s    				rr  c                 C  sB   |du r| j }t|ƒ\}}t||t| dƒd� |d | _t| _| S )z5
    Add equality methods to *cls* with *attrs*.
    Nrh  r¹  )r{   rk  rU   rÃ   rh  rj  rº  r   r   r   Ú_add_eq
  s    ÿ
rÇ  c                 C  sî   t dd„ | D ƒƒ}dd„ |D ƒ}t|d< t|d< t|d< g }|D ]N\}}}|rVd| n
d	| d
 }|tkrvd||f nd|||f }	| |	¡ q@d |¡}
|du r¨d}n|d }ddddddddddddd|› d|
› d�dd g}d! |¡|fS )"zC
    Create the source and globs for a __repr__ and return it.
    c                 s  s6   | ].}|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_script.<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_script.<locals>.<dictcomp>r
   r  r   r¶  zgetattr(self, "z", NOTHING)z	%s={%s!r}z%s={%s_repr(%s)}r•   Nz1{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¿   )rB   r
   r  r   r.   rƒ   r¬   )rl   rB  Zattr_names_with_reprsrM   Zattribute_fragmentsr�   rÉ  rd   ÚaccessorÚfragmentZrepr_fragmentZcls_name_fragmentrÄ   r   r   r   rA    sN    þÿÿÿý
ñrA  c                 C  s>   |du r| j }t||ƒ\}}t||t| dƒd� |d | _| S )z%
    Add a repr method to *cls*.
    Nr   r¹  )r{   rA  rU   rÃ   r   )rx   rB  rl   rL   rM   r   r   r   Ú	_add_reprT  s    ÿ
rÍ  c                 C  s–   t | ƒ}|du rFt| tƒsFt| ƒ}t|ddƒdu r>d}t|ƒ‚t|ƒS t| ddƒ}|du r’|dur€t|ddƒ}|dur€|| _|S | ›d�}t|ƒ‚|S )aµ  
    Return the tuple of *attrs* attributes for a class or instance.

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

    Args:
        cls (type): Class or instance to introspect.

    Raises:
        TypeError: If *cls* is neither a class nor an *attrs* instance.

        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.
    .. versionchanged:: 26.1.0 Add support for instances.
    Nr{   z0Passed object must be a class or attrs instance.ú! is not an attrs-decorated class.)r   r@   r*   r€   r<   rÓ   r{   r   )rx   Zgeneric_baseÚtype_rG   rl   r   r   r   rÓ   c  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
    zPassed object must be a class.r{   NrÎ  c                 S  s   i | ]}|j |“qS r   r¦   r§   r   r   r   r!  °  r›   zfields_dict.<locals>.<dictcomp>)r@   r*   r<   r€   r   )rx   rG   rl   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   Z_run_validatorsrÓ   r�   r-   r€   r�   )rÖ   rŠ   r   r   r   r   r  ³  s    	
r  c                 C  s   |  | ¡}|od|jv S )z>
    Check if the attribute name comes from a slot class.
    r%  )r–   rw   )Úa_namerˆ   rx   r   r   r   Ú_is_slot_attrÅ  s    
rÒ  ztuple[str, dict, dict]c                 C  s   |
d uo|
t ju}|r&|r&d}t|ƒ‚|p,|}g }i }|D ]n}|jsP|jtu rPq:| |¡ |||j< |jd ur”|du rŽ|jt jurŽd}t|ƒ‚d}q:|r:|jt jur:d}q:t	|||||||||	|||rÊdndƒ\}}}| j
tjv rö| tj| j
 j¡ | t|dœ¡ |�rtj|d< |||fS )Nz$Frozen classes can't use on_setattr.Tre  r  )r   Ú	attr_dictr½   )r   rw  r=   r1   r,   r   rƒ   r�   r9   Ú_attrs_to_init_scriptr!   r*  Úmodulesr
  rw   r´   rµ   )rx   rl   Úpre_initÚpre_init_has_argsÚ	post_initrR  r   rS  rˆ   r˜  Zcls_on_setattrrX  Úhas_cls_on_setattrrG   Úneeds_cached_setattrZfiltered_attrsrÓ  rŠ   rL   rM   r   r   r   r   r^  Í  sP    ÿ



ô

r^  ©ri   Ú	value_varÚhas_on_setattrrP   c                 C  s   d| › d|› d�S )zJ
    Use the cached object.setattr to set *attr_name* to *value_var*.
    ú
_setattr('rµ  rª  r   ©ri   rÜ  rÝ  r   r   r   Ú_setattr  s    rà  Ú	Converter©ri   rÜ  rÝ  r2   rP   c                 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©ri   rÜ  rÝ  r2   r   r   r   Ú_setattr_with_converter  s    rå  )ri   rÏ   rÝ  rP   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à  )ri   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ç  ro   )rR  r   rˆ   c                   s`   | du rV|du rdt tfS dddddœ‡ fdd„}ddd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   rJ   rì   rÛ  c                   s&   t | ˆ ƒrt| ||ƒS d| › d|› �S ©Nú_inst_dict['z'] = )rÒ  rà  rß  ©rˆ   r   r   Ú
fmt_setterK  s    
z&_determine_setters.<locals>.fmt_setterrá  râ  c                   s4   |st | ˆ ƒrt| |||ƒS d| › d| | |¡› �S rè  )rÒ  rå  rã  rä  rê  r   r   Úfmt_setter_with_converterS  s
    ÿz5_determine_setters.<locals>.fmt_setter_with_converter)z_inst_dict = self.__dict__)rà  rå  ræ  rç  )rR  r   rˆ   rë  rì  r   rê  r   Ú_determine_setters;  s    
ýrí  )rl   rö   rô   Úcall_pre_initr×  Úcall_post_initÚdoes_cache_hashrˆ   r˜  rÚ  rÙ  Úmethod_namerP   c           $   
   C  s¶  |r
dgng }|	r|  d¡ t|||ƒ\}}}| |¡ g }g }g }g }i }ddi}| D �]®}|jrn|  |¡ |j}|jdupŒ|jtjuoŒ|
}|j}t	|j
tƒ}|r°|j
jr°dnd}|jdurÖt	|jtƒsÖt|jƒ}n|j}|jdu �r¼|�rdt|jf }|du�r8|  |||d|› d	� ||ƒ¡ |j|| |j¡< n|  |||d|› d	� |ƒ¡ |j
j||< nT|du�rž|  ||d
|› d�||ƒ¡ |j|| |j¡< n|  ||d
|› d�|ƒ¡ �n|j
tu�rN|�sN|› d|› d�}|j�rò|  |¡ n|  |¡ |  |¡ |du�r8|  |||||ƒ¡ |j|| |j¡< n|  ||||ƒ¡ �nv|�rX|› d�}|j�rr|  |¡ n|  |¡ |  |¡ |  d|› d�¡ t|jf }|du�r|  d|||||ƒ ¡ |  d¡ |  d|||d | d	 ||ƒ ¡ |j|| |j¡< nB|  d||||ƒ ¡ |  d¡ |  d|||d | d	 |ƒ ¡ |j
j||< nl|j�rl|  |¡ n|  |¡ |  |¡ |du�r²|  |||||ƒ¡ |j|| |j¡< n|  ||||ƒ¡ |jdu rX|jdu�rð|du �rð|j||< qX|durX|jrX|j||< qX|�rtt|d< |  d¡ |D ]L}d|j }d|j }|  d|› d|› d|j› d	�¡ |j||< |||< �q&|�r„|  d¡ |�rÈ|�r²|�r¤dt› d�} ndt› d�} ndt› d�} |  | ¡ |�rôd  d!d"„ | D ƒ¡}!|  d#|!› d	�¡ d$ |¡}d$ |¡}|�rh||�rd$nd› d%d$ |¡› �7 }d$ d&d'„ d(d"„ |D ƒD ƒ¡}"||�rZd$nd7 }||"7 }|�r„|�r„d)|› 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)rP   Nr   rI   FrÊ  rª  zattr_dict['z
'].defaultz=attr_dict['z=NOTHINGzif z is not NOTHING:r¯  zelse:Tr   z#if _config._run_validators is True:Z__attr_validator_Z__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ž   P	  r›   z(_attrs_to_init_script.<locals>.<genexpr>zBaseException.__init__(self, r•   z*, c                 S  s   g | ]}|› d |› �‘qS )ú=r   )r’   Zkw_arg_namer   r   r   r¥   Z	  s   þz)_attrs_to_init_script.<locals>.<listcomp>c                 s  s   | ]}|  d ¡d V  qdS )rò  r   N)Úsplit)r’   Zkwar   r   r   rž   ]	  r›   zself.__attrs_pre_init__(r   z
    zdef z):
    Úpassr¿   )rƒ   rí  rÂ   r-   r�   r9   r   rw  r:   r@   r,   r?   Ú
takes_selfr2   rá  r1   Ú_INIT_FACTORY_PATÚ_get_global_namerF   r   r4   r*   Ú_first_param_typer   r/  r¬   )$rl   rö   rô   rî  r×  rï  rð  rˆ   r˜  rÚ  rÙ  rñ  rÄ   Úextra_linesrë  rì  rÔ   Zpre_init_argsZkw_only_argsZattrs_to_validateZnames_for_globalsr   rŠ   ri   rÝ  Zarg_nameZhas_factoryZ
maybe_selfr2   Zinit_factory_nameÚargZval_nameZinit_hash_cacheÚvalsZpre_init_kw_only_argsÚNLr   r   r   rÔ  j  sr   üÿ




ÿ
üÿ	ÿýÿ

üÿ	ÿ
ýÿ


ÿÿÿ



ÿÿÿ
üÿÿ
ÿÿ
ýÿÿ


ÿÿÿ



 




"ýÿÿûrÔ  )r�   rP   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¶   r	  s    r¶   c                   @  s^   e Zd ZdZdZddd„Zdd„ Zedd	d
ddœdd„ƒZdd„ Z	dd„ Z
dd„ Zdd„ ZdS )r®   az  
    *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.
    - ``alias_is_default`` (`bool`): Whether the ``alias`` was automatically
      generated (``True``) or explicitly provided by the user (``False``).
    - ``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*
    .. versionadded:: 26.1.0 *alias_is_default*

    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:   rª   NFc                 C  s  t ||p
||p|dƒ\}}}}t | ¡}|d|ƒ |d|ƒ |d|ƒ |d|ƒ |d|ƒ |d|ƒ |d|ƒ |d	|ƒ |d
|ƒ |d|ƒ |d|ƒ |d|	r¬t t|	ƒ¡ntƒ |d|
ƒ |d|ƒ |d|ƒ |d|ƒ |d|ƒ |d|d u rø|d u n|ƒ d S )NTr�   r,   r-   r.   r5   r6   r7   r8   r0   r1   r2   r3   r*   r4   r}   r9   r:   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:   rª   Úbound_setattrr   r   r   r  Â	  s<    ÿ











ÿû




þzAttribute.__init__c                 C  s   t ‚d S r'   )r   rÎ   r   r   r   rÍ   þ	  s    zAttribute.__setattr__rJ   rE   rì   )r�   r¡   r4   c                 C  sŠ   |d u r|j }n|j d ur.d|› d�}t|ƒ‚| ||j|j|jd |j|jd|j||j|j	d u rb|n|j	|j
|j|j|j|j|j|jd u ƒS )Nz>Type annotation and type argument cannot both be present for 'z'.F)r*   r=   Ú_defaultÚ
_validatorr.   r0   r1   r3   r2   r4   r5   r6   r7   r8   r9   r:   )rx   r�   r¡   r4   r*   rG   r   r   r   r¯   
  s4    
ízAttribute.from_counting_attrc                 K  sj   t   | ¡}| | ¡ ¡ d|v r:d|vr:t |¡ddƒ n,d|v rfd|vrf| jrft |¡dt|jƒƒ |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
        r:   rª   Fr�   )ÚcopyÚ	_setattrsr«   r´   rµ   rª   r¶   r�   )r   rÕ   Únewr   r   r   r‚   $
  s    
ÿþü
ÿzAttribute.evolvec                   s   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ž   H
  s   ÿz)Attribute.__getstate__.<locals>.<genexpr>©rB   r%  r   r   r   r   rñ   D
  s    þzAttribute.__getstate__c                 C  sj   t |ƒt | jƒk rTtt| j|ƒƒ}| d¡du pD| d¡t|d ƒk}g |¢|‘R }|  t| j|ƒ¡ dS )r  r:   Nr�   )rZ   r%  rõ   rJ  r–   r¶   r  )r   rK  Z
state_dictrª   r   r   r   rò   M
  s    ÿþ
ÿþzAttribute.__setstate__c                 C  sL   t  | ¡}|D ]8\}}|dkr*|||ƒ q|||r@t t|ƒ¡ntƒ qd S )Nr3   )r´   rµ   rþ  rÿ  rõ   r   )r   Zname_values_pairsr  r�   rÏ   r   r   r   r  ^
  s    
ÿûzAttribute._setattrs)NNNFNNNNNNN)N)r    r!   r"   r#   r%  r  rÍ   r3  r¯   r‚   rñ   rò   r  r   r   r   r   r®   }	  s,   /           ì
< ÿ" 	r®   c                 C  s6   g | ].}t |td |dkd dd|dkddt|ƒd�‘qS )Nrª   TFr3   ©r�   r,   r-   r.   r/   r5   r7   r0   r1   r}   r:   ©r®   r   r¶   r$  r   r   r   r¥   n
  s   óõr¥   rÁ  c                 C  s   g | ]}|j d kr|‘qS r|   r¦   r§   r   r   r   r¥   ‚
  r›   c                 C  s    g | ]}|j r|jd kr|‘qS r|   )r0   r�   r§   r   r   r   r¥   „
  r›   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  s8   | ]0}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   NTFr  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  Ö
  s"    z_CountingAttr.__init__c                 C  s$   | j du r|| _ nt| j |ƒ| _ |S )zŒ
        Decorator that adds *meth* to the list of validators.

        Returns *meth* unchanged.

        .. versionadded:: 17.1.0
        N)r  rD   ©r   rm  r   r   r   r-   û
  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?   r  r   r   r   r,   	  s    
z_CountingAttr.default)r    r!   r"   r#   r%  rB   r®   r{   r  r  r-   r,   r   r   r   r   rE   ˆ
  s:   îÿñá1%rE   c                   @  sL   e Zd ZdZG dd„ dejƒZG dd„ dejƒZdZdd„ Z	e
d	d
„ ƒZdS )r°   a¥  
    Effective class properties as derived from parameters to `attr.s()` or
    `define()` decorators.

    This is the same data structure that *attrs* uses internally to decide how
    to construct the final class.

    Warning:

        This feature is currently **experimental** and is not covered by our
        strict backwards-compatibility guarantees.


    Attributes:
        is_exception (bool):
            Whether the class is treated as an exception class.

        is_slotted (bool):
            Whether the class is `slotted <slotted classes>`.

        has_weakref_slot (bool):
            Whether the class has a slot for weak references.

        is_frozen (bool):
            Whether the class is frozen.

        kw_only (KeywordOnly):
            Whether / how the class enforces keyword-only arguments on the
            ``__init__`` method.

        collected_fields_by_mro (bool):
            Whether the class fields were collected by method resolution order.
            That is, correctly but unlike `dataclasses`.

        added_init (bool):
            Whether the class has an *attrs*-generated ``__init__`` method.

        added_repr (bool):
            Whether the class has an *attrs*-generated ``__repr__`` method.

        added_eq (bool):
            Whether the class has *attrs*-generated equality methods.

        added_ordering (bool):
            Whether the class has *attrs*-generated ordering methods.

        hashability (Hashability): How `hashable <hashing>` the class is.

        added_match_args (bool):
            Whether the class supports positional `match <match>` over its
            fields.

        added_str (bool):
            Whether the class has an *attrs*-generated ``__str__`` method.

        added_pickling (bool):
            Whether the class has *attrs*-generated ``__getstate__`` and
            ``__setstate__`` methods for `pickle`.

        on_setattr_hook (Callable[[Any, Attribute[Any], Any], Any] | None):
            The class's ``__setattr__`` hook.

        field_transformer (Callable[[Attribute[Any]], Attribute[Any]] | None):
            The class's `field transformers <transform-fields>`.

    .. versionadded:: 25.4.0
    c                   @  s    e Zd ZdZdZdZdZdZdS )zClassProps.HashabilityzO
        The hashability of a class.

        .. versionadded:: 25.4.0
        ZhashableZhashable_cacheZ
unhashableZleave_aloneN)r    r!   r"   r#   r”  rú   r•  r“  r   r   r   r   rù   d  s   rù   c                   @  s   e Zd ZdZdZdZdZdS )zClassProps.KeywordOnlyzw
        How attributes should be treated regarding keyword-only parameters.

        .. versionadded:: 25.4.0
        r¤   ÚyesÚforceN)r    r!   r"   r#   r²   r–  r³   r   r   r   r   r±   t  s
   r±   ©rþ   rô   r÷   rö   r4   ró   r‹  rŒ  r�  rŽ  rø   r�  r�  r  rÿ   rº   c                 C  sd   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|| _|| _|| _|| _|| _d S r'   r  )r   rþ   rô   r÷   rö   r4   ró   r‹  rŒ  r�  rŽ  rø   r�  r�  r  rÿ   rº   r   r   r   r  •  s     zClassProps.__init__c                 C  s   | j tjju p| j tjju S r'   )rø   r°   rù   r”  rú   r   r   r   r   r—  ¹  s    þzClassProps.is_hashableN)r    r!   r"   r#   r$   ÚEnumrù   r±   r%  r  rg   r—  r   r   r   r   r°     s   D$r°   c                 C  s.   g | ]&}t |td dd dddddt|ƒd�‘qS )NTFr	  r
  r$  r   r   r   r¥   Á  s   óõ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'   r  )r   rF   rõ  r   r   r   r  ê  s    zFactory.__init__c                   s   t ‡ fdd„ˆ jD ƒƒS )r  c                 3  s   | ]}t ˆ |ƒV  qd S r'   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  N)rJ  r%  r  )r   rK  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  s(   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¥   ü  s   ôöc                   @  sZ   e Zd ZdZdZdddœdd„Zedddœd	d
„ƒZddd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ø  Z_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sxˆ jrx‡ fdd„ˆ _nˆ j ˆ _| ¡ }|d urœ|ˆ jjd< d S )Nc                   s
   ˆ   | ¡S r'   ©r2   )rÏ   r  Ú__r   r   r   rš   6  r›   z$Converter.__init__.<locals>.<lambda>c                   s   ˆ   | |¡S r'   r  )rÏ   Úinstancer  r   r   r   rš   8  s   ÿc                   s   ˆ   | |¡S r'   r  )rÏ   r  rb  r   r   r   rš   <  s   ÿrP   )	r2   rõ  r  r   Úget_first_param_typerø  r  Úget_return_typerp   )r   r2   rõ  r  ÚexÚrtr   r   r   r  -  s    
zConverter.__init__rJ   )ri   rP   c                 C  s
   d| › �S )zh
        Return the name that a converter for an attribute name *attr_name*
        would have.
        Z__attr_converter_r   )ri   r   r   r   r÷  F  s    zConverter._get_global_name)ri   rÜ  rP   c                 C  s‚   | j s"| js"|  |¡› d|› d�S | j rJ| jrJ|  |¡› d|› d|› d�S | j rf|  |¡› 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   ri   rÜ  r   r   r   rã  N  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  r  r   r   r   r   rñ   _  s    ýzConverter.__getstate__c                 C  s   | j f i |¤Ž dS )z+
        Load instance from state.
        NrŠ  )r   rK  r   r   r   rò   j  s    zConverter.__setstate__N)r    r!   r"   r#   r%  r  r4  r÷  rã  rñ   rò   r   r   r   r   rá    s   	c                 C  s(   g | ] }t |td dd dddddd�
‘qS r  r  r$  r   r   r   r¥   q  s   ôör  c                   sl  t  d| ¡} 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r�|ˆ d< |dur |ˆ d< |	dur°|	ˆ d< t	 
| |i ‡ fd	d
„¡}
t tt¡�& t d¡j dd¡|
_W d  ƒ n1 �s0    Y  | dd¡}t|| d¡| d¡dƒ\|d< |d< tf 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)``

    .. warning::

        It is *your* duty to ensure that the class name and the attribute names
        are valid identifiers. ``make_class()`` will *not* validate them for
        you.

    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*
    .. versionchanged:: 25.2.0 Class names can now be unicode.
    ÚNFKCc                 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
  )rB  ©rh   r   r   rš   Î  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   )ÚunicodedataÚ	normalizer@   rõ   rA   rB   r<   Úpopr
  rþ  Ú	new_classr  r  r  r=   r*  Ú	_getframeÚ	f_globalsr–   r!   r‚  rÚ   r«   rp   )r�   rl   ÚbasesZ
class_bodyZattributes_argumentsr?  rG   rÖ  rØ  Z	user_initrÏ  r/   rx   r   r!  r   Ú
make_class†  sN    0

ÿ&üýÿr*  )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   r,  r  r   r   r   r   r+  ñ  s   r+  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@   r+  r,  rB   )Z
validatorsrû  r-   r   r   r   rD   þ  s    ÿýrD   c                    sº   t dd„ ˆ D ƒƒ}|r$‡ fdd„}n‡ fdd„}ˆ sPtdƒ}|j ||dœ¡ nTtˆ d ƒ ¡ }|rn||jd	< ˆ d
 }tsŠt|tƒrŠ|j	}t|ƒ 
¡ }|r¤||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ž   %  r›   zpipe.<locals>.<genexpr>c                   s,   ˆ D ]"}t |tƒr|| ||ƒn|| ƒ} q| S r'   r-  )ru  rÖ   rb  r.  ©Ú
convertersr   r   Úpipe_converter)  s    ÿzpipe.<locals>.pipe_converterc                   s   ˆ D ]}|| ƒ} q| S r'   r   )ru  r.  r/  r   r   r1  3  s    
ÚA)ru  rP   r   ru  rW   rP   Tr  )r€  r   rp   r
  r   r  r   r@   rá  r  r  )r0  Zreturn_instancer1  r2  ÚtÚlastr  r   r/  r   rC     s&    


rC   )NrI   )N)T)NNNNNNNFFTFFFFFNNFFNNNTNT)N)NN)lÚ
__future__r   r  r  r  r$   rû   r0  r\   r*  rþ  r#  r  Úcollections.abcr   r   Ú	functoolsr   Útypingr   r   r   rI   r
   r   r   r   r   r   r   r   r   Ú
exceptionsr   r   r   r   ÚobjectrÍ   r´   rö  ru   r/  rÿ  r   r  rC   r  r  r   r  r   r   Úintr&   rH   rU   ra   rj   rk   rv   ry   r�   rŽ   r»   rÆ   rÐ   rÒ   r‚   r×   r‚  r;   r‡  rl   rÚ   r‘  rÃ   rU  r»  rj  rk  rr  rÇ  rA  rÍ  rÓ   rÐ  rÒ  r^  rà  rå  ræ  rç  rí  rÔ  r¶   r®   r%  Z_arE   r°   Z_casr?   Ú_frá  r*  r+  rD   r   r   r   r   Ú<module>   sB   		
ñ
q  ü ü#! 4:    K, ÿ
                         ç
  
H%8
9
3E
/&  
 rò
þû	  #ò'óbóÿÿ
k
