HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/attr/__pycache__/_make.cpython-39.pyc
a

�,�h�y�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZddlmZddlmZmZmZddlmZmZmZddlmZmZmZmZmZmZdd	lm Z m!Z!m"Z"m#Z#e$j%Z&d
Z'dZ(dZ)e
�*i�Z+e$�Z,e�-ej.ej/�Z0Gd
d�dej1�Z2e2j3Z3Gdd�de4�Z5e3ddddddddddddddfdd�Z6d�dddddd�dd�Z7d�dddddd�dd �Z8dd!d"d#�d$d%�Z9Gd&d'�d'e�Z:d(d)�Z;d*d+�Z<d,d-�d.d/�Z=d0d1�Z>d'd-�d2d3�Z?d4d5�Z@d6d7�ZAd8d9�ZBd:d;�ZCGd<d=�d=�ZDd>d?�ZEd@dA�ZFd�dBdC�ZGd�dDdE�ZHeHZIdFdG�ZJd"dddH�dIdJ�ZKd"dKdLdLdMdN�dOdP�ZLd"dKdQ�dRdS�ZMdTdU�ZNdVdMdW�dXdY�ZOdZd[�ZPd�d\d]�ZQdMd-�d^d_�ZRd�d`da�ZSdbdc�ZTddde�ZUdfdg�Z/dhdi�ZVdjd-�dkdl�ZWdddLddm�dndo�ZXdddLdpddq�drds�ZYdddLddt�dudv�ZZdddLdpddq�dwdx�Z[dLdLdydz�d{d|�Z\dKdLdLdLdLdLdLdydLdLdLddjd}�
d~d�Z]ddd��d�d��Z^Gd�d��d��Z_d�d��e_j`D�ZaeMeQeSe_ead��d�d��eaD�d��d�d��eaD�d��Z_Gd�d��d��ZbeQeSeb��ZbGd�d��d��Zcd�d��ecj`D�ZdeMeQeSecedd��edd��edd��ZcGd�dp�dp�Zed�d��d�D�ZdeMeQeSeeedd��edd��edd��Zee$fdfd�d��ZfeHddd��Gd�d��d���Zgd�d��Zhd�d��Z-dS)��)�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)ztyping.ClassVarz
t.ClassVar�ClassVarztyping_extensions.ClassVarZ_attrs_cached_hashc@s(eZdZdZe��Zdd�Zdd�ZdS)�_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.
    cCsdS)N�NOTHING���selfrr�;/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/attr/_make.py�__repr__Jsz_Nothing.__repr__cCsdS)NFrrrrr�__bool__Msz_Nothing.__bool__N)	�__name__�
__module__�__qualname__�__doc__�enum�autorrrrrrrr=s
rc@s"eZdZdZed�dfdd�ZdS)�_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.
    NrcCs||fS�Nr)rZ_none_constructor�_argsrrr�
__reduce__esz_CacheHashWrapper.__reduce__)r r!r"r#�typer)rrrrr&Ysr&TFcCs�t|||d�\}}}}|dur:|dur:|dur:d}t|��|	durr|turVd}t|��t|	�sjd}t|��t|	�}|dur~i}t|
ttf�r�t	j
|
�}
|r�t|ttf�r�t|�}|r�t|ttf�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*
    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/r0r1r3r*r2�factoryr4r5r7r9r:r6r8�msgrrr�attribisR7��
�rH��strzdict[str, Any] | NonezMapping[str, object] | None�None)�script�globs�locs�filename�returncCst||d�}t|||�dS)z[
    Evaluate the script with the given global (globs) and local (locs)
    variables.
    �execN)�compile�eval)rLrMrNrO�bytecoderrr�_compile_and_eval�s
rUzdict[str, Any])rLrOrM�localsrPc	Csz|durin|}d}|}t|�d|�d�|f}tj�||�}||krFqh|dd��d|�d�}|d7}qt||||�|S)zP
    Cache the script with _linecache_, compile it and return the _locals_.
    Nr	T����-�>)�len�
splitlines�	linecache�cache�
setdefaultrU)	rLrOrMrVrN�count�
base_filenameZlinecache_tupleZold_valrrr�_linecache_and_compile�s
�
raz	list[str]r*)�cls_name�
attr_namesrPcCsF|�d�}i}t|�D] \}}|fdd�}t|�||<qt|tf|�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
AttributescSs||Sr'r)r�irrr�gettersz&_make_attr_tuple_class.<locals>.getter)�	enumerate�propertyr*rB)rbrcZattr_class_name�bodyrd�	attr_namererrr�_make_attr_tuple_classs

rjc@s&eZdZUded<ded<ded<dS)�_Attributesr*�attrs�list[Attribute]�
base_attrs�dict[str, type]Zbase_attrs_mapN)r r!r"�__annotations__rrrrrks
rkcCs2t|�}|�d�r(|�d�r(|dd�}|�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)Zannotrrr�
_is_class_var"srvcCs
||jvS)zR
    Check whether *cls* defines *attrib_name* (and doesn't just inherit it).
    )�__dict__)�clsZattrib_namerrr�_has_own_attribute3sryz'tuple[list[Attribute], dict[str, type]]�rPcCs�g}i}t|jdd��D]H}t|dg�D]6}|js*|j|vr@q*|jdd�}|�|�|||j<q*qg}t�}t|�D](}|j|vr�qv|�d|�|�	|j�qv||fS)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�seenrrr�_collect_base_attrs:s"

r�cCsng}i}|jdd�D]N}t|dg�D]<}|j|vr6q&|jdd�}|�|j�|�|�|||j<q&q||fS)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	rWr{Tr|)rr�r�r�r�r�)rxr�rnr�r�r�rrr�_collect_base_attrs_broken[s

r�c	s0|j�t|��|dur$t|���}n�|dur�dd����D�}g}t�}���D]H\}	}
t|
�rbqP|�|	���|	t�}|j	t
ur�t|�}|�|	|f�qP||}|r�t
dd�t|�fdd�d	��d
��ntdd����D�d
d�d	�}tj���fdd�|D�}
|�r&t|dd�|
D��\}}nt|dd�|
D��\}}|�r`dd�|
D�}
dd�|D�}||
}|du�r�t|||��}d}dd�|D�D]H}|du�r�|jtu�r�d|��}t|��|du�r�|jtu�r�d}�q�|D]$}|j�s�t�|�dt|j���q�dd�|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`.
    NTcSsh|]\}}|jtur|�qSr��	__class__rE��.0r��attrrrr�	<setcomp>�s
�z#_transform_attrs.<locals>.<setcomp>z1The following `attr.ib`s lack a type annotation: �, cs��|�jSr')�get�counter)�n)�cdrr�<lambda>��z"_transform_attrs.<locals>.<lambda>)�key�.css$|]\}}|jtur||fVqdSr'r�r�rrr�	<genexpr>�s
�z#_transform_attrs.<locals>.<genexpr>cSs
|djS�Nr	)r�)�errrr��r�cs"g|]\}}�||��|���qSr)r�)r�ri�ca)�anns�fcarr�
<listcomp>�sz$_transform_attrs.<locals>.<listcomp>cSsh|]
}|j�qSr�r��r�r�rrrr��r�cSsh|]
}|j�qSrr�r�rrrr��r�cSsg|]}|jdd��qS�T)r4�r�r�rrrr��r�cSsg|]}|jdd��qSr�r�r�rrrr��r�Fcss&|]}|jdur|jdur|VqdS)FN)r1r4r�rrrr��r�zlNo mandatory attributes allowed after an attribute with a default value or factory.  Attribute in question: r:cSsg|]
}|j�qSrr�r�rrrr��r�)rwrrA�itemsr�rvr�r�rr�rErHr�r�join�sorted�	Attribute�from_counting_attrr�r�rBr,r=r:�_OBJ_SETATTR�__get__�_default_init_alias_forr�rjr rk)rx�these�auto_attribsr4�collect_by_mro�field_transformerZca_listZca_namesZannot_namesrir*r�ZunannotatedZ	own_attrsrnr�rlZhad_defaultrGrcZ
AttrsClassr)r�r�r�r�_transform_attrsws�
�

������	��
�

r�cCsngd�}|dur|�d�n|�gd��|�ddg�t|d�}|tj|d�}td�|�||d	|id
�dS)N)	zdef 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�rar�)r�r�rx�linesZunique_filename�globrrr�_make_cached_property_getattr�s.
��
��
���r�cCs,t|t�r$|dvr$t�|||�dSt�dS)z4
    Attached to frozen classes as __setattr__.
    )�	__cause__�__context__�
__traceback__�__suppress_context__�	__notes__N)r@�
BaseException�__setattr__r�rr��valuerrr�_frozen_setattrssr�cCs*t|t�r"|dvr"t�||�dSt�dS)z4
    Attached to frozen classes as __delattr__.
    )r�N)r@r��__delattr__r)rr�rrr�_frozen_delattrs(sr�c	Os�z
|\}Wn,ty6dt|��d�}t|�d�Yn0|j}t|�}|D].}|jsVqJ|j}|j}||vrJt||�||<qJ|fi|��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=rZr<r��fieldsr1r�r:r�)	�args�changes�instrGrxrlr�riZ	init_namerrrr�3s %
�r�c@s�eZdZdZdZdd�dd�Zdd�Zd	d
�dd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d+d,�d-d.�Zd+d+d,�d/d0�Zd1S)2�
_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*�rxcCst||||||�\}}}||_|r,t|j�ni|_||_dd�|D�|_||_tdd�|D��|_	||_
||_||_|	|_
tt|dd��|_d|_|jr�|j}t�|�}t|j�dk|_tt|dd��|_t|�|_|
|_||_|
|_d|_|j|jd	<|�rt|jd
<t|jd<d|_n�|tt j!t j"fv�r�d}}|D]8}|j#du�rPd}|j$du�r`d}|�r<|�r<�qv�q<|tk�r�|�s�|�r�|t j!k�r�|�r�|t j"k�r�|�s�d|_|�r�|�%�\|jd
<|jd<g|_&d|_'t(|jd��r�t(|jd��s|j)|_*n|j+|_*dS)NcSsh|]
}|j�qSrr�r�rrrr��r�z)_ClassBuilder.__init__.<locals>.<setcomp>css|]}|jVqdSr'r�r�rrrr��r�z)_ClassBuilder.__init__.<locals>.<genexpr>�__attrs_pre_init__Fr	�__attrs_post_init__r{r�r�T�__getstate__�__setstate__r!r"),r�r��dictrwr�r�r�r�rBr�r�r�r�r��boolr�r�r�r��inspect�	signaturerZ�
parametersr�r�r�r�r�r�r�r��_DEFAULT_ON_SETATTRr�validate�convertr-r2�_make_getstate_setstater�r��hasattr�_add_method_dunders_safer��_add_method_dunders_unsafe)rrxr��slots�frozen�weakref_slot�getstate_setstater�r4�
cache_hash�is_excr�r9Zhas_custom_setattrr�rlrnZbase_mapZ
pre_init_funcZpre_init_signatureZ
has_validatorZ
has_converterr�rrr�__init__�s��
	


�
����������
z_ClassBuilder.__init__cCsd|jj�d�S)Nz<_ClassBuilder(cls=z)>)r�r rrrrr�sz_ClassBuilder.__repr__rKrzcCsld�dd�|jD��}i}|jD]\}}}|�|�q t|t|jd�|�}|jD]\}}}||j|�qPdS)z=
        Evaluate any registered snippets in one go.
        r�cSsg|]}|d�qS)rr)r�Zsnippetrrrr��r�z0_ClassBuilder._eval_snippets.<locals>.<listcomp>�methodsN)r�r��updaterar�r�r�)rrLrM�_Z
snippet_globsrN�hookrrr�_eval_snippets�s
�z_ClassBuilder._eval_snippetscCsT|��|jdur|��}n|��}tr2t�|�}t|dd�rPd|jvrP|�	�|S)z�
        Finalize class based on the accumulated configuration.

        Builder cannot be used after calling this method.
        T�__attrs_init_subclass__N)
rr��_create_slots_class�_patch_original_classr
�abcZupdate_abstractmethodsr�rwr)rrxrrr�build_class
s



��z_ClassBuilder.build_classc	Cs�|j}|j}|jrj|jD]P}||vrt||t�turt�t��t	||�Wd�q1s^0Yq|j
��D]\}}t|||�qt|j
s�t|dd�r�d|_|js�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�rr�r�r�)rrx�
base_namesr�r�rrrr"s&
��*�z#_ClassBuilder._patch_original_classc
s��fdd��j��D�}�jsTd|d<�jsT�jjD]��j�dd�r4t|d<qTq4i}d}�jj	dd�D]:��j�dd	�d	ur�d
}|�
�fdd�t�dg�D��qlt�j
���j}�jr�dt�jdd
�vr�d|vr�|s�|d7}dd�|��D�}g}|�r�t�j�}|��D]F\}}	||f7}||=|�|	�t�|	�j}
|
tjju�r|
||<�q|�d�}|d	u�rx|�|�t||�j�|d<�fdd�|D���fdd�|��D���fdd��D��|�
���j�r��t�t��|d<�jj|d<t�j��jj�jj|�}t�|j� �|�D]�}
t!|
t"t#f��rHt|
j$dd	�}n(t!|
t%��rdt|
j&dd	�}nt|
dd	�}|�sz�q$|D]8}z|j'�ju}Wnt(�y�Yn0|�r~||_'�q~�q$|S)zL
        Build and return a new class with a `__slots__` attribute.
        cs2i|]*\}}|gt�j��d�d�Rvr||�qS)rw�__weakref__)rBr��r��k�vrrr�
<dictcomp>Js�z5_ClassBuilder._create_slots_class.<locals>.<dictcomp>Frr�r	rWrNTcsi|]}|t�|��qSr�r��r�r�)r�rrris��	__slots__r)rcSs"i|]\}}t|t�r||j�qSr)r@r�func)r�r�Zcached_proprrrrzs
�r�csg|]}|�vr|�qSrrr)rrrr��r�z5_ClassBuilder._create_slots_class.<locals>.<listcomp>csi|]\}}|�vr||�qSrr)r�ZslotZslot_descriptor)�
slot_namesrrr�s�csg|]}|�vr|�qSrrr)�reused_slotsrrr��r�r"�__closure__))r�r�r�r�r��	__bases__rwr�r�rr�r�r�r�r�r�rr�r�r��return_annotation�	Parameter�emptyr�r��_HASH_CACHE_FIELDrBr"r*r �	itertools�chain�valuesr@�classmethod�staticmethod�__func__rg�fget�
cell_contentsr=)rr�Zexisting_slotsZweakref_inherited�namesr�Z&additional_closure_functions_to_updateZclass_annotationsr�r�
annotationr�rx�itemZ
closure_cells�cell�matchr)r�rrrrrrFs�
�

��
�����





�
�


�z!_ClassBuilder._create_slots_classcs8t�j|�\}}�fdd�}�j�|||f�d�_�S)Ncs��|d�|d<dS)Nr�r���cls_dictrMrrr�_attach_repr�sz,_ClassBuilder.add_repr.<locals>._attach_reprT)�_make_repr_scriptr�r�r�r�)r�nsrLrMr1rrr�add_repr�s
z_ClassBuilder.add_reprcCs.|jsd}t|��dd�}|�|�|jd<|S)Nz3__str__ can only be generated if a __repr__ exists.cSs|��Sr'�rrrrr�__str__�sz&_ClassBuilder.add_str.<locals>.__str__r6)r�r=r�r�)rrGr6rrr�add_str�sz_ClassBuilder.add_strcs<tdd�|jD����fdd�}|j���fdd�}||fS)zF
        Create custom __setstate__ and __getstate__ methods.
        css|]}|dkr|VqdS)rNr)r�Zanrrrr��sz8_ClassBuilder._make_getstate_setstate.<locals>.<genexpr>cs�fdd��D�S)�9
            Automatically created by attrs.
            csi|]}|t�|��qSrrrrrrr�r�zQ_ClassBuilder._make_getstate_setstate.<locals>.slots_getstate.<locals>.<dictcomp>rr)�state_attr_namesrr�slots_getstate�sz=_ClassBuilder._make_getstate_setstate.<locals>.slots_getstatecsft�|�}t|t�r4t�|�D]\}}|||�qn �D]}||vr8||||�q8�rb|td�dS)r8N)r�r�r@rB�zipr )r�stateZ_ClassBuilder__bound_setattrr�r��Zhash_caching_enabledr9rr�slots_setstate�s

z=_ClassBuilder._make_getstate_setstate.<locals>.slots_setstate)rBr�r�)rr:r>rr=rr��s�z%_ClassBuilder._make_getstate_setstatecCsd|jd<|S�N�__hash__)r�rrrr�make_unhashables
z_ClassBuilder.make_unhashablecsHt�j�j�j�jd�\}}dddd��fdd�}�j�|||f��S)N�r�r�r�rK)r0rNrPcs��|d�|d<dSr?r.)r0rNrrr�attach_hashsz+_ClassBuilder.add_hash.<locals>.attach_hash)�_make_hash_scriptr�r�r�r�r�r�)rrLrMrCrrr�add_hashs�
z_ClassBuilder.add_hashcs`t�j�j�j�j�j�j�j�j�j	�j
�jdd�\}}���fdd�}�j�
|||f��S)NF��
attrs_initcs |d}�|_��|�|d<dS)Nr��rpr��r0rMr1�rrrr�_attach_init2sz,_ClassBuilder.add_init.<locals>._attach_init��_make_init_scriptr�r�r�r�r�r�r�r�r�r�r�r�r�)rrLrMrKrrJr�add_init"s"�z_ClassBuilder.add_initcCs|�dd��|jd<|S)Nc[st|fi|��Sr'r�)rr�rrrr�=r�z+_ClassBuilder.add_replace.<locals>.<lambda>�__replace__)r�r�rrrr�add_replace;s�
z_ClassBuilder.add_replacecCstdd�|jD��|jd<dS)Ncss |]}|jr|js|jVqdSr')r1r4r�)r��fieldrrrr�Bs�z/_ClassBuilder.add_match_args.<locals>.<genexpr>�__match_args__)rBr�r�rrrr�add_match_argsAs�z_ClassBuilder.add_match_argscs`t�j�j�j�j�j�j�j�j�j	�j
�jdd�\}}���fdd�}�j�
|||f��S)NTrFcs |d}�|_��|�|d<dS)N�__attrs_init__rHrIrJrr�_attach_attrs_initXsz8_ClassBuilder.add_attrs_init.<locals>._attach_attrs_initrL)rrLrMrUrrJr�add_attrs_initHs"�z_ClassBuilder.add_attrs_initcs>�j}t�j�\}}�fdd�}�j�|||f�t|d<�S)Ncs��|d�|d<dS)N�__eq__r.r/rrr�
_attach_eqfsz(_ClassBuilder.add_eq.<locals>._attach_eq�__ne__)r��_make_eq_scriptr�r�r�rY)rr�rLrMrXrrr�add_eqasz_ClassBuilder.add_eqcs>�j}�fdd�t�j�j�D�\|d<|d<|d<|d<�S)Nc3s|]}��|�VqdSr'r.)r��methrrrr�rs�z*_ClassBuilder.add_order.<locals>.<genexpr>�__lt__�__le__�__gt__�__ge__)r��_make_orderr�r�)rr�rrr�	add_orderos

�z_ClassBuilder.add_ordercs�i�|jD],}|jp|j}|r
|tjur
||f�|j<q
�s@|S|jrRd}t|���fdd�}d|jd<|�	|�|jd<d|_
|S)Nz7Can't combine custom __setattr__ with on_setattr hooks.csDz�|\}}Wnty&|}Yn0||||�}t|||�dSr')�KeyErrorr�)rr��valr�rZnval�Zsa_attrsrrr��s
z._ClassBuilder.add_setattr.<locals>.__setattr__Trr�)r�r9r�r�NO_OPr�r�r=r�r�r�)rr�r9rGr�rrer�add_setattrys


z_ClassBuilder.add_setattrr)�methodrPcCs6|jj|_|jj�d|j��|_d|jj�d�|_|S)z@
        Add __module__ and __qualname__ to a *method*.
        r��$Method generated by attrs for class )r�r!r"r r#�rrhrrrr��s

�z(_ClassBuilder._add_method_dunders_unsafecCs�t�t��|jj|_Wd�n1s*0Yt�t��&|jj�d|j��|_Wd�n1sj0Yt�t��"d|jj�d�|_Wd�n1s�0Y|S)zL
        Add __module__ and __qualname__ to a *method* if possible.
        Nr�ri)r
rrr�r!r"r r#rjrrrr��s(40z&_ClassBuilder._add_method_dunders_safeN)r r!r"r#rr�rrrrrr4r7r�rArErNrPrSrVr[rbrgr�r�rrrrr�ms.k$
)
 r�cCst|dur(t|du|duf�r(d}t|��|dur8||fS|durD|}|durP|}|durl|durld}t|��||fS)��
    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/r5r7�
default_eqrGrrr�_determine_attrs_eq_order�srqc	Cs�|dur(t|du|duf�r(d}t|��dd�}|durP||�\}}||||fS|durd|d}}n||�\}}|dur�||}}n||�\}}|dur�|dur�d}t|��||||fS)rkNrlcSs t|�rd|}}nd}||fS)z8
        Decide whether a key function is used.
        TN)r>)r�r�rrr�decide_callable_or_boolean�sz>_determine_attrib_eq_order.<locals>.decide_callable_or_booleanFTrmrn)	r/r5r7rprGrrZcmp_keyr6r8rrrr;�s"r;cCsF|dus|dur|S|dur(|dur(|S|D]}t||�r,dSq,|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_detectZdundersr,Zdunderrrr�_determine_whether_to_implement�s
rucs��dur"ddl}|jtd�dd�t|||d�\��|dur@|�	t�
ttf�rXtj�
��
����������	�
���
�������fdd�}|dur�|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*.
    NrzQThe `repr_ns` argument is deprecated and will be removed in or after August 2025.�)�
stacklevelcs"�p
t|�}�duot|t�}�o*t|d�}|r@|r@d}t|��t|��|�t|��d�d����|��
|��}t|��d�r�|����dur�|��t|��d�}|s�|dur�|�	�|s�t|��d�r�|�
��s�|���	dur��dur�t|d	�r�d
�	�	du�r(�	d
u�r(�	du�r(d}t|���	d
u�sL�	du�rF|d
u�sL|�r`��r�d}t|��nL�	du�s��	du�r�|du�r�|du�r�|�
�n��r�d}t|��|��t|�
�d
��r�|��n|����r�d}t|��t�r�t|d��s�|��t�r��rt|d��s|��|��S)NTr�z/Can't freeze a class with a custom __setattr__.)r�r�)r,r5)rWrY)r]r^r_r`r@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.rOrR)�_has_frozen_base_class�
issubclassr�ryr=r�rur4r7r[rbrgr<rErArNrVrrPr
rSr)rx�	is_frozenr�Zhas_own_setattrrGZbuilderr5�r�rt�auto_excr�r�Zeq_r�r�r�r0r1r4�
match_argsr9Zorder_r.�repr_nsr�rJr�r�rr�wrap�s�����
�����$

���
�
���zattrs.<locals>.wrap)	�warnings�warn�DeprecationWarningrqr@rArBrrC)Z	maybe_clsr�rr.r/r0r1r�r�r�rJr�r4r�r}r5r7rtr�r�r9r�r~�unsafe_hashr�r�rr|rrls"\��
4nrlcCs
|jtuS)zV
    Check whether *cls* has a frozen ancestor by looking at its
    __setattr__.
    )r�r�r�rrrrysry)rx�	func_namerPc	Cs$d|�d|j�dt|d|j��d�S)zF
    Create a "filename" suitable for a function being generated.
    z<attrs generated � r�r"rY)r!r�r )rxr�rrrr�
s��r�rmr�ztuple[str, dict])rxrlr�r�rPcstdd��D���d}tt|d���i�d}d�d�|sB|d7}n |d	7}|d
7}d���d7�|g�������fd
d�}|r��|dt�d��|r�|dt�d�|d���|dd�n|dt�d�|d���|dt���n
|d|�d���}|�fS)Ncss0|](}|jdus$|jdur|jdur|VqdS)TN)r0r5r�rrrr�sz$_make_hash_script.<locals>.<genexpr>�        r0zdef __hash__(selfzhash((z))z):z, *zC, _cache_wrapper=__import__('attr._make')._make._CacheHashWrapper):z_cache_wrapper(�)c	s���||�|d��d�g��D]Z}|jrhd|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�r6r�r�)�prefix�indentr��cmp_name�rlZclosing_bracesrMZ	hash_funcZmethod_linesZ	type_hashrr�append_hash_computation_lines/s
��
�z8_make_hash_script.<locals>.append_hash_computation_lineszif self.z	 is None:zobject.__setattr__(self, '�', rv�self.� = zreturn self.zreturn r�)rBr0r�r�r r�)rxrlr�r��tabZhash_defr�rLrr�rrDs>�
��

rD)rxrlcCs6t||ddd�\}}t||t|d�d�|d|_|S)z%
    Add a hash method to *cls*.
    FrBr@�rO)rDrUr�r@�rxrlrLrMrrr�	_add_hash\s�
�
r�cCs|�|�}|turtS|S)z^
    Check equality and either forward a NotImplemented or
    return the result negated.
    )rW�NotImplemented)r�other�resultrrrrYjs
rYrA)rlrPcCs�dd�|D�}gd�}i}|r�|�d�|D]�}|jrxd|j�d�}|j||<|�d|�d|j�d	|�d
|j�d�	�n|�d|j�d
|j���||dur,|d�d�|d<q,|�d�n
|�d�d�|�}||fS)z6
    Create __eq__ method for *cls* with *attrs*.
    cSsg|]}|jr|�qSr)r5r�rrrr�zr�z#_make_eq_script.<locals>.<listcomp>)zdef __eq__(self, other):z-    if other.__class__ is not self.__class__:z        return NotImplementedz
    return  (rr�r�r�z) == z(other.r�r�z
 == other.rWz andz    )z    return Truer�)r�r6r�r�)rlr�rMr�r�rLrrrrZvs&

 �

rZcsVdd��D���fdd���fdd�}�fdd�}�fd	d
�}�fdd�}||||fS)
z9
    Create ordering methods for *cls* with *attrs*.
    cSsg|]}|jr|�qSr)r7r�rrrr��r�z_make_order.<locals>.<listcomp>cs tdd��fdd��D�D��S)z&
        Save us some typing.
        css"|]\}}|r||�n|VqdSr'r)r�r�r�rrrr��s�z6_make_order.<locals>.attrs_to_tuple.<locals>.<genexpr>c3s |]}t�|j�|jfVqdSr')r�r�r8r���objrrr��s)rBr��rlr�r�attrs_to_tuple�s

��z#_make_order.<locals>.attrs_to_tuplecs |j|jur�|��|�kStS�z1
        Automatically created by attrs.
        �r�r��rr��r�rrr]�sz_make_order.<locals>.__lt__cs |j|jur�|��|�kStSr�r�r�r�rrr^�sz_make_order.<locals>.__le__cs |j|jur�|��|�kStSr�r�r�r�rrr_�sz_make_order.<locals>.__gt__cs |j|jur�|��|�kStSr�r�r�r�rrr`�sz_make_order.<locals>.__ge__r)rxrlr]r^r_r`r)rlr�rra�s				racCsB|dur|j}t|�\}}t||t|d�d�|d|_t|_|S)z5
    Add equality methods to *cls* with *attrs*.
    NrWr�)r{rZrUr�rWrYr�rrr�_add_eq�s�
r�c
Cs�tdd�|D��}dd�|D�}t|d<t|d<t|d<g}|D]N\}}}|rVd|n
d	|d
}|tkrvd||fnd|||f}	|�|	�q@d
�|�}
|dur�d}n|d}ddddddddddddd|�d|
�d�dd g}d!�|�|fS)"zC
    Create the source and globs for a __repr__ and return it.
    css6|].}|jdur|j|jdur"tn|j|jfVqdS)FTN)r.r�r1r�rrrr��s
�z$_make_repr_script.<locals>.<genexpr>cSs$i|]\}}}|tkr|d|�qS)�_repr)r.)r�r��rrrrrr�sz%_make_repr_script.<locals>.<dictcomp>r
rrr�zgetattr(self, "z", NOTHING)z	%s={%s!r}z%s={%s_repr(%s)}r�Nz1{self.__class__.__qualname__.rsplit(">.", 1)[-1]}z.{self.__class__.__name__}zdef __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�)rBr
rrr.r�r�)
rlr3Zattr_names_with_reprsrMZattribute_fragmentsr�r�rd�accessor�fragmentZ
repr_fragmentZcls_name_fragmentr�rrrr2�sN�����
�r2cCs>|dur|j}t||�\}}t||t|d�d�|d|_|S)z%
    Add a repr method to *cls*.
    Nrr�)r{r2rUr�r)rxr3rlrLrMrrr�	_add_reprs�
r�cCsvt|�}|dur&t|t�s&d}t|��t|dd�}|durr|dur`t|dd�}|dur`||_|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.)rr@r*r<r�r{r)rxZgeneric_baserGrlrrrr�,s
r�cCsJt|t�sd}t|��t|dd�}|dur<|�d�}t|��dd�|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�cSsi|]}|j|�qSrr�r�rrrrtr�zfields_dict.<locals>.<dictcomp>)r@r*r<r�r)rxrGrlrrr�fields_dictZs

r�cCsDtjdurdSt|j�D]&}|j}|dur|||t||j��qdS)z�
    Validate all attributes on *inst* that have a validator.

    Leaves all exceptions through.

    Args:
        inst: Instance of a class with *attrs* attributes.
    FN)rZ_run_validatorsr�r�r-r�r�)r�r�rrrrr�ws	
r�cCs|�|�}|od|jvS)z>
    Check if the attribute name comes from a slot class.
    r)r�rw)Za_namer�rxrrr�
_is_slot_attr�s
r�ztuple[str, dict, dict]c
Cs|
duo|
tju}|r&|r&d}
t|
��|p,|}g}i}|D]b}|jsP|jturPq:|�|�|||j<|jdur�|dur�d}
t|
��d}q:|r:|jtjur:d}q:t	|||||||||	|||r�dnd�\}}}|j
tjvr�|�
tj|j
j�|�
t|d��|�r
tj|d<|||fS)Nz$Frozen classes can't use on_setattr.TrTr�)r�	attr_dictr�)rrfr=r1r,rr�r�r9�_attrs_to_init_scriptr!�sys�modulesr�rwr�r�)rxrl�pre_init�pre_init_has_args�	post_initr�r�r�r�r�Zcls_on_setattrrG�has_cls_on_setattrrG�needs_cached_setattrZfiltered_attrsr�r�rLrMrrrrrM�sP�



�

rM�ri�	value_var�has_on_setattrrPcCsd|�d|�d�S)zJ
    Use the cached object.setattr to set *attr_name* to *value_var*.
    �
_setattr('r�r�r�rir�r�rrr�_setattr�sr��	Converter�rir�r�r2rPcCsd|�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�rir�r�r2rrr�_setattr_with_converter�sr�)rir�r�rPcCs |rt||d�Sd|�d|��S)zo
    Unless *attr_name* has an on_setattr hook, use normal assignment. Otherwise
    relegate to _setattr.
    Tr�r�)r�)rir�r�rrr�_assign�sr�cCs*|rt||d|�Sd|�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�rrr�_assign_with_converter�sr�ro)r�r�r�cs`|durV|durdttfSddddd��fdd�}dddddd	��fd
d�}d||fSdttfS)
zg
    Determine the correct setter functions based on whether a class is frozen
    and/or slotted.
    TrrJr�r�cs&t|��rt|||�Sd|�d|��S�N�_inst_dict['z'] = )r�r�r��r�rr�
fmt_setters
z&_determine_setters.<locals>.fmt_setterr�r�cs4|st|��rt||||�Sd|�d|�||���Sr�)r�r�r�r�r�rr�fmt_setter_with_converters
�z5_determine_setters.<locals>.fmt_setter_with_converter)z_inst_dict = self.__dict__)r�r�r�r�)r�r�r�r�r�rr�r�_determine_setters�s
�r�)
rlr{�
is_slotted�
call_pre_initr��call_post_init�does_cache_hashr�r�r�r��method_namerPc$
Cs�|r
dgng}|	r|�d�t|||�\}
}}|�|
�g}g}g}i}ddi}|D�]�}|jrj|�|�|j}|jdup�|jtjuo�|
}|j}t	|j
t�}|r�|j
jr�dnd}|j
dur�t	|j
t�s�t|j
�}n|j
}|jdu�r�|�r`t|jf}|du�r4|�|||d|�d	�||��|j
||�|j�<n|�|||d|�d	�|��|j
j||<nT|du�r�|�||d
|�d�||��|j
||�|j�<n|�||d
|�d�|���n�|j
tu�r@|�s@|�d|�d�}|j�r�|�|�n
|�|�|du�r*|�|||||��|j
||�|j�<n|�||||���nb|�r@|�d
�}|j�rd|�|�n
|�|�|�d|�d��t|jf}|du�r�|�d|||||��|�d�|�d|||d|d	||��|j
||�|j�<nB|�d||||��|�d�|�d|||d|d	|��|j
j||<nb|j�rT|�|�n
|�|�|du�r�|�|||||��|j
||�|j�<n|�||||��|jdurT|jdu�r�|du�r�|j||<qT|durT|jrT|j||<qT|�rRt|d<|�d�|D]L}d|j}d|j}|�d|�d|�d|j�d	��|j||<|||<�q|�rb|�d�|�r�|�r�|�r�dt�d�}ndt�d�}ndt�d�}|�|�|�r�d �d!d"�|D��} |�d#| �d	��d$�|�}|}!|�r@||�r�d$nd�d%d$�|���7}d$�d&d'�d(d"�|D�D��}"|!|!�r2d$nd7}!|!|"7}!|�r\|�r\d)|!�d	�|d*<d+}#d,|�d|�d-|�r~|#�|�nd.�d/�||fS)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.
    zself.__attrs_pre_init__()z$_setattr = _cached_setattr_get(self)rPNrrIFr�r�zattr_dict['z
'].defaultz=attr_dict['z=NOTHINGzif z is not NOTHING:r�zelse:Trz#if _config._run_validators is True:Z__attr_validator_Z__attr_z(self, z, self.zself.__attrs_post_init__()r�z', None)r�z	'] = Noner�z = Noner�css |]}|jrd|j��VqdS)r�N)r1r�r�rrrr�	r�z(_attrs_to_init_script.<locals>.<genexpr>zBaseException.__init__(self, r�z*, cSsg|]}|�d|���qS)�=r)r�Zkw_arg_namerrrr�	s�z)_attrs_to_init_script.<locals>.<listcomp>css|]}|�d�dVqdS)r�rN)�split)r�Zkwarrrr�	r�zself.__attrs_pre_init__(rz
    zdef z):
    �passr�)r�r�r�r-r�r9rrfr:r@r,r?�
takes_selfr2r�r1�_INIT_FACTORY_PAT�_get_global_namerFrr4r*�_first_param_typerr r�)$rlr{r�r�r�r�r�r�r�r�r�r�r�Zextra_linesr�r�r�Zkw_only_argsZattrs_to_validateZnames_for_globalsrr�rir�Zarg_nameZhas_factoryZ
maybe_selfr2Zinit_factory_name�argZval_nameZinit_hash_cache�valsZ
pre_init_argsZpre_init_kw_only_args�NLrrrr�.sj��




�
��	���

��	�
��

���


���
���
��
���

���



 



"����r�)r�rPcCs
|�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�rrrr�2	sr�c
@s\eZdZdZdZddd�Zdd�Zedd	d
d�dd
��Zdd�Z	dd�Z
dd�Zdd�ZdS)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.r5r6r7r8r0r1r3r*r2r4r}r9r:NFcCs�t||p
|
|p|d�\}
}}}t�|�}|d|�|d|�|d|�|d|�|d|
�|d|�|d|�|d	|�|d
|�|d|�|d|�|d
|	r�t�t|	��nt�|d|
�|d|�|d|�|d|�|d|�dS)NTr�r,r-r.r5r6r7r8r0r1r2r3r*r4r}r9r:)r;r�r��types�MappingProxyTyper��_EMPTY_METADATA_SINGLETON)rr�r,r-r.r/r0r1r}r3r*r2r4r5r6r7r8r9r:�
bound_setattrrrrr�~	s4�











��



zAttribute.__init__cCst�dSr')rr�rrrr��	szAttribute.__setattr__rJrE)r�r�cCst|dur|j}n|jdur.d|�d�}t|��|||j|j|jd|j|jd|j||j|j	|j
|j|j|j
|j|j�S)Nz>Type annotation and type argument cannot both be present for 'z'.F)r*r=�_default�
_validatorr.r0r1r3r2r4r5r6r7r8r9r:)rxr�r�r*rGrrrr��	s2
�zAttribute.from_counting_attrcKst�|�}|�|���|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�)rr��newrrrr��	s
zAttribute.evolvecst�fdd��jD��S)�(
        Play nice with pickle.
        c3s*|]"}|dkrt�|�nt�j�VqdS)r3N)r�r�r3rrrrr��	s�z)Attribute.__getstate__.<locals>.<genexpr>�rBrrrrrr��	s�zAttribute.__getstate__cCs|�t|j|��dS�r�N)r�r;r�rr<rrrr��	szAttribute.__setstate__cCsLt�|�}|D]8\}}|dkr*|||�q|||r@t�t|��nt�qdS)Nr3)r�r�r�r�r�r�)rZname_values_pairsr�r�r�rrrr��	s
��zAttribute._setattrs)
NNNFNNNNNN)N)
r r!r"r#rr�r�r$r�r�r�r�r�rrrrr�=	s(,�
7	r�cCs2g|]*}t|tddddd|dkddt|�d��qS)NTFr3)r�r,r-r.r/r5r7r0r1r}r:)r�rr�rrrrr�
s��r�r�cCsg|]}|jdkr|�qSr|r�r�rrrr�
r�cCs g|]}|jr|jdkr|�qSr|)r0r�r�rrrr�
r�c@sneZdZdZdZgedd�dD���eddddddd	dd	ddd	dd	dd
��RZdZdd
�Z	dd�Z
dd�ZdS)rEa
    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:r2r�r5r6r0r1r4r3r9r7r8r.r*ccs8|]0}t|t|�tddddddddddddd�VqdS)NTF�r�r:r,r-r.r/r0r1r4r5r6r7r8r}r9)r�r�rrrrrr�=
s$��z_CountingAttr.<genexpr>)	r�r�r.r5r7r0r1r9r:r3NTFr�rcCsttjd7_tj|_||_||_||_||_||_||_|
|_	||_
||_||_||_
|	|_|
|_||_||_dSr�)rE�cls_counterr�r�r�r2r.r5r6r7r8r0r1r3r*r4r9r:)rr,r-r.r/r0r1r2r3r*r4r5r6r7r8r9r:rrrr�o
s"z_CountingAttr.__init__cCs$|jdur||_nt|j|�|_|S)z�
        Decorator that adds *meth* to the list of validators.

        Returns *meth* unchanged.

        .. versionadded:: 17.1.0
        N)r�rD�rr\rrrr-�
s
z_CountingAttr.validatorcCs |jturt�t|dd�|_|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�rrr?r�rrrr,�
s
z_CountingAttr.default)r r!r"r#rrBr�r{r�r�r-r,rrrrrE!
s:����1%rEc@s.eZdZdZdZddd�Zdd�Zdd	�Zd
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*
    �rFr�FcCs||_||_dSr'r�)rrFr�rrrr��
szFactory.__init__cst�fdd��jD��S)r�c3s|]}t�|�VqdSr'rrrrrr��
r�z'Factory.__getstate__.<locals>.<genexpr>r�rrrrr��
szFactory.__getstate__cCs&t|j|�D]\}}t|||�qdSr�)r;rr)rr<r�r�rrrr��
szFactory.__setstate__N)F)r r!r"r#rr�r�r�rrrrr?�
s

r?cCs(g|] }t|tddddddddd�
�qS�NTF)
r�r,r-r.r/r5r7r0r1r}�r�rrrrrr��
s
��c@sZeZdZdZdZddd�dd�Zeddd�d	d
��Zdddd�dd
�Zdd�Z	dd�Z
dS)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�cs�|�_|�_|�_t|�}|���_�js@�js@�fdd��_nF�jr\�js\�fdd��_n*�jsx�jrx�fdd��_n�fdd��_|��}|dur�|�jjd<dS)Ncs
��|�Sr'�r2)r�r�__rrrr�r�z$Converter.__init__.<locals>.<lambda>cs��||�Sr'r�)r��instancer�rrrr�s�cs��||�Sr'r�)r�r�rQrrrr�s�cs��|||�Sr'r�)r�r�rQrrrr�#s�rP)	r2r�r�r�get_first_param_typer�r��get_return_typerp)rr2r�r��ex�rtrrrr�s
zConverter.__init__rJ)rirPcCs
d|��S)zh
        Return the name that a converter for an attribute name *attr_name*
        would have.
        Z__attr_converter_r)rirrrr�+szConverter._get_global_name)rir�rPcCs�|js"|js"|�|��d|�d�S|jrJ|jrJ|�|��d|�d|�d�S|jrf|�|��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�)rrir�rrrr�3szConverter._fmt_converter_callcCs|j|j|jd�S)zx
        Return a dict containing only converter and takes_self -- the rest gets
        computed when loading.
        �r2r�r�r�rrrrr�Ds�zConverter.__getstate__cCs|jfi|��dS)z+
        Load instance from state.
        Nrxr�rrrr�OszConverter.__setstate__N)r r!r"r#rr�r%r�r�r�r�rrrrr��
s	cCs(g|] }t|tddddddddd�
�qSr�r�rrrrr�Vs
��r�c
slt�d|�}t|t�r|}n*t|ttf�r:dd�|D�}nd}t|��|�dd�}|�dd�}|�dd�}	i�|dur���|�|dur�|�d<|dur�|�d<|	dur�|	�d<t	�
||i�fd	d
��}
t�t
t��&t�d�j�dd
�|
_Wd�n1�s0Y|�dd�}t||�d�|�d�d�\|d<|d<tfd|i|��|
�}dd�|��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.
    �NFKCcSsi|]}|t��qSr)rHr�rrrr�r�zmake_class.<locals>.<dictcomp>z(attrs argument must be a dict or a list.r�Nr�r�cs
|���Sr')r�)r3�rhrrr��r�zmake_class.<locals>.<lambda>r	r �__main__r/r5r7Tr�cSs"i|]\}}|jdur||j�qSr')r*rrrrr�s)�unicodedata�	normalizer@r�rArBr<�popr�r��	new_classr
rrr=r��	_getframe�	f_globalsr�r!rqr�r�rp)
r�rl�basesZ
class_bodyZattributes_argumentsr0rGr�r�Z	user_init�type_r/rxrr�r�
make_classksN0

�&���r)r�r�c@seZdZdZe�Zdd�ZdS)�
_AndValidatorz2
    Compose many validators to a single one.
    cCs|jD]}||||�qdSr')�_validators)rr�r�r�rrrrr��s
z_AndValidator.__call__N)r r!r"r#rHrr�rrrrr�srcGs6g}|D] }|�t|t�r |jn|g�qtt|��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@rrrB)Z
validatorsr�r-rrrrD�s��rDcs�tdd��D��}|r$�fdd�}n�fdd�}�sPtd�}|j�||d��nTt�d���}|rn||jd	<�d
}ts�t|t�r�|j	}t|��
�}|r�||jd<|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
    css|]}t|t�VqdSr'�r@r�)r��crrrr�
r�zpipe.<locals>.<genexpr>cs,�D]"}t|t�r||||�n||�}q|Sr'r)rdr�rQr	��
convertersrr�pipe_converters�zpipe.<locals>.pipe_convertercs�D]}||�}q|Sr'r)rdr	r
rrrs
�A)rdrPrrdrWrPTr�)rorrpr�rr�rr@r�r�r�)rZreturn_instancerr
�t�lastr�rr
rrC�s&


rC)NrI)N)T)NNNNNNNFFTFFFFFNNFFNNNTN)N)NN)i�
__future__rrr
r�r$r�r!r\r�r�r��collections.abcrr�	functoolsr�typingrrrrIr
rrr
rrrrr�
exceptionsrrrr�objectr�r�r�rur r�r�r	rCr�r�r��Enumrr�intr&rHrUrarjrkrvryr�r�r�r�r�r�r�r�rqr;rurlr�ryr�rDr�rYrZrar�r2r�r�r�r�rMr�r�r�r�r�r�r�r�rZ_arEr?Z_fr�rrrDrrrr�<module>s. 		
�
n��#!l4:N,�
�
d
H%8
9
.E

/&K�
��	'
�d
���
k