관리-도구
편집 파일: _make.cpython-39.opt-1.pyc
a ����Pͣ_�X���������������������@���sb��d�dl�mZmZmZ�d�dlZd�dlZd�dlZd�dlZd�dlZd�dl Z d�dl mZ�ddlm Z mZ�ddlmZmZmZmZmZmZmZ�ddlmZmZmZmZmZ�ejZdZ d Z!d Z"dZ#dZ$ei��Z%e��Z&G�d d��de�Z'e'��Z(G�dd��de)�Z*e(dddddddddddddfdd�Z+dd��Z,e,dg�d��Z-dd��Z.dd��Z/dd��Z0dd ��Z1d!d"��Z2d#d$��Z3d%d&��Z4e�rrd'd(��Z5nd)d(��Z5d*d+��Z6G�d,d-��d-e�Z7d.Z8d/d0��Z9d{d1d2�Z:d|d3d4�Z;e;Z<e�r�d5d6��Z=nd7d6��Z=d8d9��Z>d:d;��Z?d<d=��Z@d>d?��ZAd@dA��ZBdBdC��ZCdDdE��ZDd}dFdG�ZEe�F��ZGdHdI��ZHd~dJdK�ZIdLdM��ZJdNdO��ZKdPdQ��ZLdRdS��ZMdTdU��ZNdVdW��ZOdXdY��ZPdZd[��ZQd\d]��ZRd^d_��ZSe�r�dd`da�ZTdbdc��ZUddde��ZVG�dfdg��dge�ZWdhdi��eWjXD��ZYeAeEeIeWeYdj�dkdi��eYD��dj�dldi��eYD��dj�ZWG�dmdn��dne�ZZeEeIeZ��ZZe;ddddo�G�dpdq��dqe��Z[effdrds�Z\e;dddt�G�dudv��dve��Z]dwdx��Z^dydz��Z_dS�)������)�absolute_import�division�print_functionN)� itemgetter����)�_config�setters)�PY2�PYPY�isclass� iteritems�metadata_proxy�ordered_dict�set_closure_cell)�DefaultAlreadySetError�FrozenInstanceError�NotAnAttrsClassError�PythonTooOldError�UnannotatedAttributeErrorz__attr_converter_%sz__attr_factory_{}z= {attr_name} = _attrs_property(_attrs_itemgetter({index})))ztyping.ClassVarz t.ClassVar�ClassVarZ_attrs_cached_hashc�����������������������s,���e�Zd�ZdZdZ��fdd�Zdd��Z���ZS�)�_Nothingz� Sentinel class to indicate the lack of a value when ``None`` is ambiguous. ``_Nothing`` is a singleton. There is only ever one of it. Nc��������������������s"���t�jd�u�rtt�|���|��t�_t�jS��N)r���� _singleton�super�__new__��cls�� __class__���./usr/lib/python3.9/site-packages/attr/_make.pyr���;���s���� z_Nothing.__new__c�����������������C���s���dS�)N�NOTHINGr�����selfr���r���r ����__repr__@���s����z_Nothing.__repr__)�__name__� __module__�__qualname__�__doc__r���r���r$���� __classcell__r���r���r���r ���r���2���s���r���c�������������������@���s6���e�Zd�ZdZer edfdd�Zned�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. )r�����Nc�����������������C���s���||fS�r���r����r#���Z_none_constructor�_argsr���r���r ���� __reduce__Z���s����z_CacheHashWrapper.__reduce__Nr���c�����������������C���s���||fS�r���r���r,���r���r���r ���r.���_���s����)r%���r&���r'���r(���r ����getattrr.����typer���r���r���r ���r*���J���s���r*���TFc�����������������C���s����t�|||d�\}}|dur2|dur2|dur2td��| durb|�turJtd��t| �sZtd��t| �}�|du�rni�}t| ttf�r�t j | ��} |r�t|ttf�r�t|��}|r�t|ttf�r�t |��}t|�||d|||||| ||| d� S�)aG�� Create a new attribute on a class. .. warning:: Does *not* do anything unless the class is also decorated with `attr.s`! :param default: A value that is used if an ``attrs``-generated ``__init__`` is used and no value is passed while instantiating or the attribute is excluded using ``init=False``. If the value is an instance of `Factory`, its callable will be used to construct a new value (useful for mutable data types like lists or dicts). If a default is not set (or set manually to `attr.NOTHING`), a value *must* be supplied when instantiating; otherwise a `TypeError` will be raised. The default can also be set using decorator notation as shown below. :type default: Any value :param callable factory: Syntactic sugar for ``default=attr.Factory(factory)``. :param validator: `callable` that is called by ``attrs``-generated ``__init__`` methods after the instance has been initialized. They receive the initialized instance, the `Attribute`, and the passed value. The return value is *not* inspected so the validator has to throw an exception itself. If a `list` is passed, its items are treated as validators and must all pass. Validators can be globally disabled and re-enabled using `get_run_validators`. The validator can also be set using decorator notation as shown below. :type validator: `callable` or a `list` of `callable`\ s. :param repr: Include this attribute in the generated ``__repr__`` method. If ``True``, include the attribute; if ``False``, omit it. By default, the built-in ``repr()`` function is used. To override how the attribute value is formatted, pass a ``callable`` that takes a single value and returns a string. Note that the resulting string is used as-is, i.e. it will be used directly *instead* of calling ``repr()`` (the default). :type repr: a `bool` or a `callable` to use a custom function. :param bool eq: If ``True`` (default), include this attribute in the generated ``__eq__`` and ``__ne__`` methods that check two instances for equality. :param bool order: If ``True`` (default), include this attributes in the generated ``__lt__``, ``__le__``, ``__gt__`` and ``__ge__`` methods. :param bool cmp: Setting to ``True`` is equivalent to setting ``eq=True, order=True``. Deprecated in favor of *eq* and *order*. :param Optional[bool] hash: Include this attribute in the generated ``__hash__`` method. If ``None`` (default), mirror *eq*'s value. This is the correct behavior according the Python spec. Setting this value to anything else than ``None`` is *discouraged*. :param bool init: Include this attribute in the generated ``__init__`` method. It is possible to set this to ``False`` and set a default value. In that case this attributed is unconditionally initialized with the specified default value or factory. :param callable converter: `callable` that is called by ``attrs``-generated ``__init__`` methods to convert attribute's value to the desired format. It is given the passed-in value, and the returned value will be used as the new value of the attribute. The value is converted before being passed to the validator, if any. :param metadata: An arbitrary mapping, to be used by third-party components. See `extending_metadata`. :param type: The type of the attribute. In Python 3.6 or greater, the preferred method to specify the type is using a variable annotation (see `PEP 526 <https://www.python.org/dev/peps/pep-0526/>`_). This argument is provided for backward compatibility. Regardless of the approach used, the type will be stored on ``Attribute.type``. Please note that ``attrs`` doesn't do anything with this metadata by itself. You can use it as part of your own code or for `static type checking <types>`. :param kw_only: Make this attribute keyword-only (Python 3+) in the generated ``__init__`` (if ``init`` is ``False``, this parameter is ignored). :param on_setattr: Allows to overwrite the *on_setattr* setting from `attr.s`. If left `None`, the *on_setattr* value from `attr.s` is used. Set to `attr.setters.NO_OP` to run **no** `setattr` hooks for this attribute -- regardless of the setting in `attr.s`. :type on_setattr: `callable`, or a list of callables, or `None`, or `attr.setters.NO_OP` .. 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 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�metadatar0����kw_only�eq�order� on_setattr) �_determine_eq_order� TypeErrorr!���� ValueError�callable�Factory� isinstance�list�tupler����pipe�and_� _CountingAttr)r2���r3���r4���r5���r6���r7���r9���r0���r8����factoryr:���r;���r<���r=���r���r���r ����attribc���sJ������� �rJ���c�����������������C���sx���d��|��}d��|�dg}|rDt|�D�]\}}|�tj�||d���q$n |�d��ttd�}ttd�|�dd �|��||�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{}Attributeszclass {}(tuple):z __slots__ = ())�index� attr_namez pass)Z_attrs_itemgetterZ_attrs_property� r+����exec) �format� enumerate�append�_tuple_property_patr����property�eval�compile�join)�cls_name� attr_namesZattr_class_nameZattr_class_template�irL����globsr���r���r ����_make_attr_tuple_class��s���� �� r[����_Attributes)�attrs� base_attrsZbase_attrs_mapc�����������������C���s���t�|���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. )�str� startswith�_classvar_prefixes)Zannotr���r���r ���� _is_class_var?��s����rb���c�����������������C���sJ���t�|�|t�}|tu�rdS�|�jdd��D�]}t�||d�}||u�r&�dS�q&dS�)zj Check whether *cls* defines *attrib_name* (and doesn't just inherit it). Requires Python 3. Fr���NT)r/���� _sentinel�__mro__)r���Zattrib_name�attr�base_cls�ar���r���r ����_has_own_attributeJ��s����rh���c�����������������C���s���t�|�d�r|�jS�i�S�)z$ Get annotations for *cls*. �__annotations__)rh���ri���r���r���r���r ����_get_annotations\��s���� rj���c�����������������C���s ���|�d�j�S�)zQ Key function for sorting to avoid re-creating a lambda for every class. r�����counter��er���r���r ����_counter_getterf��s����ro���c�����������������C���s����g�}i�}t�|�jdd���D�]H}t|dg��D�]6}|js*|j|v�r@q*|jdd�}|�|��|||j<�q*qg�}t��}t�|�D�](}|j|v�r�qv|�d|��|� |j��qv||fS�)zQ Collect attr.ibs from base classes of *cls*, except *taken_attr_names*. r�������__attrs_attrs__T�� inheritedr���) �reversedrd���r/���rs����name�evolverQ����set�insert�add)r����taken_attr_namesr^���� base_attr_maprf���rg���Zfiltered�seenr���r���r ����_collect_base_attrsm��s"���� r}���c�����������������C���sn���g�}i�}|�j�dd��D�]N}t|dg��D�]<}|j|v�r6q&|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���rp���rq���Trr���)rd���r/���ru���rv���ry���rQ���)r���rz���r^���r{���rf���rg���r���r���r ����_collect_base_attrs_broken���s���� r~���c�������������� ������s6��|�j��t|����|dur@dd��t|�D��}t|t�s>|jtd��n�|du��rdd������D��}g�}t��}�����D�]Z\} } t | �r�qn|� | ����| t�}t|t �s�|tu�r�t��}n t|d�}|�| |f��qn||�}t|�d k�r&td d�t|�fdd �d���d���ntdd������D��dd ��d�}��fdd�|D��} |�rXt|�dd��| D���\}}nt|�dd��| D���\}}dd��|| �D��}t|�j|�}|�r�dd��| D��} dd��|D��}||| ��}d}dd��|D��D�]D}|du��r�|jtu��r�td|f���|du��r�|jtu�r�d}�q�|du�r(||�|�}t|||f�S�)a0�� 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. *collect_by_mro* is True, collect them in the correct MRO order, otherwise use the old -- incorrect -- order. See #428. Return an `_Attributes`. Nc�����������������S���s���g�|�]\}}||f�qS�r���r���)�.0ru����car���r���r ���� <listcomp>��������z$_transform_attrs.<locals>.<listcomp>)�keyTc�����������������S���s���h�|�]\}}t�|t�r|�qS�r����rC���rH����r���ru���re���r���r���r ���� <setcomp>���s��� �z#_transform_attrs.<locals>.<setcomp>�r2���r���z1The following `attr.ib`s lack a type annotation: �, c��������������������s�������|��jS�r���)�getrl���)�n)�cdr���r ����<lambda>���r����z"_transform_attrs.<locals>.<lambda>�.c�����������������s���s$���|�]\}}t�|t�r||fV��qd�S�r���r����r����r���r���r ���� <genexpr>���s��� �z#_transform_attrs.<locals>.<genexpr>c�����������������S���s ���|�d�j�S��Nr���rk���rm���r���r���r ���r�������r����c��������������������s&���g�|�]\}}t�j||���|�d���qS�))ru���r����r0���)� Attribute�from_counting_attrr����)r���rL���r����)�annsr���r ���r�������s�����c�����������������S���s���h�|�] }|j��qS�r����ru����r���rg���r���r���r ���r�������r����c�����������������S���s���h�|�] }|j��qS�r���r����r����r���r���r ���r�������r����c�����������������S���s���g�|�] }|j��qS�r���r����r����r���r���r ���r�������r����c�����������������S���s���g�|�]}|j�d�d��qS��T)r:����rv���r����r���r���r ���r�������r����c�����������������S���s���g�|�]}|j�d�d��qS�r����r����r����r���r���r ���r�������r����Fc�����������������s���s&���|�]}|j�d�ur|jd�u�r|V��qdS�)FN)r7���r:���r����r���r���r ���r������r����znNo mandatory attributes allowed after an attribute with a default value or factory. Attribute in question: %r)�__dict__rj���r���rC���r����sortro����itemsrw���rb���ry���r����r!���rH���rJ���rQ����lenr���rV����sortedr}���r~���r[���r%���r2���r@���r\���)r����these�auto_attribsr:����collect_by_mro�field_transformerZca_listZca_namesZannot_namesrL���r0���rg���ZunannotatedZ own_attrsr^���r{���rX���Z AttrsClassr]���Zhad_defaultr���)r����r����r ����_transform_attrs���s����� � ������ �� ��� r����c�����������������C���s.���t�|�t�r$|dv�r$t�|�||��dS�t���dS�)�< Attached to frozen classes as __setattr__. )� __cause__�__context__N)rC���� BaseException�__setattr__r����r#���ru����valuer���r���r ����_frozen_setattrs��s����r����c�����������������C���s ���t����dS�)r����N�r���r����r���r���r ���r����%��s����c�����������������C���s ���t����dS�)z4 Attached to frozen classes as __delattr__. Nr����)r#���ru���r���r���r ����_frozen_delattrs,��s����r����c�������������������@���s����e�Zd�ZdZdZdd��Zdd��Zdd��Zd d ��Zdd��Z d d��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zdd��Zdd��Zdd ��Zd!S�)"� _ClassBuilderz( Iteratively build *one* class. )�_attr_names�_attrs�_base_attr_map�_base_names�_cache_hash�_cls� _cls_dict�_delete_attribs�_frozen�_has_post_init�_is_exc�_on_setattr�_slots� _weakref_slot�_has_own_setattr�_has_custom_setattrc�����������������C���s����t�||||||�\}}}||�_|r,t|j�ni�|�_||�_tdd��|D���|�_||�_t dd��|D���|�_ ||�_||�_||�_ | |�_tt|dd��|�_t|��|�_| |�_||�_| |�_d|�_|�j|�jd<�|r�t|�jd<�t|�jd<�d |�_|r�|����\|�jd <�|�jd<�d�S�)Nc�����������������s���s���|�]}|j�V��qd�S�r���r����r����r���r���r ���r����h��r����z)_ClassBuilder.__init__.<locals>.<genexpr>c�����������������s���s���|�]}|j�V��qd�S�r���r����r����r���r���r ���r����j��r�����__attrs_post_init__Frq���r�����__delattr__T�__getstate__�__setstate__)r����r�����dictr����r����r����rw���r����r����rE���r����r����r����r����r�����boolr/���r����r����r����r����r����r����r����r�����_make_getstate_setstate)r#���r���r�����slots�frozen�weakref_slot�getstate_setstater����r:���� cache_hash�is_excr����r=���Zhas_custom_setattrr����r]���r^���Zbase_mapr���r���r ����__init__K��sF����� ��z_ClassBuilder.__init__c�����������������C���s���dj�|�jjd�S�)Nz<_ClassBuilder(cls={cls})>r���)rO���r����r%���r"���r���r���r ���r$������s����z_ClassBuilder.__repr__c�����������������C���s���|�j�du�r|����S�|����S�dS�)z� Finalize class based on the accumulated configuration. Builder cannot be used after calling this method. TN)r�����_create_slots_class�_patch_original_classr"���r���r���r ����build_class���s���� z_ClassBuilder.build_classc�������������� ���C���s����|�j�}|�j}|�jrX|�jD�]>}||vrt||t�turzt||��W�q�tyT���Y�q0�q|�j� ��D�]\}}t |||��qb|�js�t|dd�r�d|_|�j s�tj|_|S�)zA Apply accumulated methods and return the class. �__attrs_own_setattr__F)r����r����r����r����r/���rc����delattr�AttributeErrorr����r�����setattrr����r����r�����objectr����)r#���r���� base_namesru���r����r���r���r ���r�������s*���� ���z#_ClassBuilder._patch_original_classc�������������� ������s����j����fdd�t�j�D��}�js\d|d<��js\�jjD�] }|j�dd�r:t j |d<��q\q:d}�jjdd��D�]}|j�dd �d urpd }�q�qp�j}�j r�dt�jdd�vr�d|vr�|s�|d 7�}��fdd�|D��}�jr�|�t��t|�|d<�t�jdd �}|d u�r||d<�t�j��jj�jj|�}|j���D�]~}t|ttf��rXt|jdd �} nt|dd �} | �sn�q4| D�]<} z| j�ju�}W�n�t�y����Y�n0�|�rrt| |���qr�q4|S�)zL Build and return a new class with a `__slots__` attribute. c��������������������s(���i�|�] \}}|t���j�d��vr||�qS�))r�����__weakref__)rE���r����)r����k�vr"���r���r ���� <dictcomp>���s����z5_ClassBuilder._create_slots_class.<locals>.<dictcomp>Fr����r����r���rp���r����NT� __slots__r���)r����c��������������������s���g�|�]}|��vr|�qS�r���r����r���ru���)r����r���r ���r�������r����z5_ClassBuilder._create_slots_class.<locals>.<listcomp>r'����__closure__)r����r���r����r����r����r����� __bases__r����r����r����r����rd���r����r����r/���r����rQ����_hash_cache_fieldrE���r0���r%����valuesrC����classmethod�staticmethod�__func__� cell_contentsr@���r���)r#���r����rf���Zweakref_inherited�namesZ slot_names�qualnamer����itemZ closure_cellsZcell�matchr���)r����r#���r ���r�������s`���� � ���� z!_ClassBuilder._create_slots_classc�����������������C���s���|���t|�j|d��|�jd<�|�S�)N)�nsr$���)�_add_method_dunders� _make_reprr����r����)r#���r����r���r���r ����add_repr��s����� z_ClassBuilder.add_reprc�����������������C���s8���|�j��d�}|d�u�rtd��dd��}|��|�|�j�d<�|�S�)Nr$���z3__str__ can only be generated if a __repr__ exists.c�����������������S���s���|�����S�r����r$���r"���r���r���r ����__str__��s����z&_ClassBuilder.add_str.<locals>.__str__r����)r����r����r@���r����)r#���r4���r����r���r���r ����add_str��s�����z_ClassBuilder.add_strc��������������������s<���t�dd��|�jD�����fdd�}|�j�����fdd�}||fS�)zF Create custom __setstate__ and __getstate__ methods. c�����������������s���s���|�]}|d�kr|V��qdS�)r����Nr���)r���Zanr���r���r ���r����&��s���z8_ClassBuilder._make_getstate_setstate.<locals>.<genexpr>c��������������������s���t���fdd��D���S�)�9 Automatically created by attrs. c�����������������3���s���|�]}t���|�V��qd�S�r����r/���r����r"���r���r ���r����.��r����zP_ClassBuilder._make_getstate_setstate.<locals>.slots_getstate.<locals>.<genexpr>�rE���r"���)�state_attr_namesr"���r ����slots_getstate*��s����z=_ClassBuilder._make_getstate_setstate.<locals>.slots_getstatec��������������������s<���t��|�t�}t�|�D�]\}}|||��q��r8|td��dS�)r����N)�_obj_setattr�__get__r�����zipr����)r#����stateZ_ClassBuilder__bound_setattrru���r�����Zhash_caching_enabledr����r���r ����slots_setstate2��s ����z=_ClassBuilder._make_getstate_setstate.<locals>.slots_setstate)rE���r����r����)r#���r����r����r���r����r ���r����!��s�����z%_ClassBuilder._make_getstate_setstatec�����������������C���s���d�|�j�d<�|�S�)N�__hash__)r����r"���r���r���r ����make_unhashableC��s���� z_ClassBuilder.make_unhashablec�����������������C���s(���|���t|�j|�j|�j|�jd��|�jd<�|�S�)N�r����r����r����)r����� _make_hashr����r����r����r����r����r"���r���r���r ����add_hashG��s������ z_ClassBuilder.add_hashc�������������� ���C���sJ���|���t|�j|�j|�j|�j|�j|�j|�j|�j |�j d�uo:|�j tju� �|�j d<�|�S�)Nr����)r����� _make_initr����r����r����r����r����r����r����r����r����r����NO_OPr����r"���r���r���r ����add_initS��s���� �� z_ClassBuilder.add_initc�����������������C���s2���|�j�}|��t|�j|�j��|d<�|��t���|d<�|�S�)N�__eq__�__ne__)r����r�����_make_eqr����r�����_make_ne�r#���r����r���r���r ����add_eqe��s�����z_ClassBuilder.add_eqc��������������������s>�����j�}��fdd�t��j��j�D��\|d<�|d<�|d<�|d<���S�)Nc�����������������3���s���|�]}����|�V��qd�S�r���)r����)r����methr"���r���r ���r����r��s����z*_ClassBuilder.add_order.<locals>.<genexpr>�__lt__�__le__�__gt__�__ge__)r�����_make_orderr����r����r��r���r"���r ���� add_ordero��s ���� �z_ClassBuilder.add_orderc��������������������s����|�j�r |�S�i���|�jD�],}|jp"|�j}|r|tjur||f��|j<�q��sJ|�S�|�jrXtd����fdd�}d|�j d<�|�� |�|�j d<�d|�_|�S�)Nz7Can't combine custom __setattr__ with on_setattr hooks.c��������������������sD���z��|�\}}W�n�t�y&���|}Y�n0�||�||�}t|�||��d�S�r���)�KeyErrorr����)r#���ru����valrg����hookZnval�Zsa_attrsr���r ���r�������s���� z._ClassBuilder.add_setattr.<locals>.__setattr__Tr����r����)r����r����r=���r����r���r����ru���r����r@���r����r����r����)r#���rg���r=���r����r���r��r ����add_setattry��s$���� � z_ClassBuilder.add_setattrc�����������������C���s|���z|�j�j|_W�n�ty ���Y�n0�zd�|�j�j|jf�|_W�n�tyN���Y�n0�zd|�j�jf�|_W�n�tyv���Y�n0�|S�)zL Add __module__ and __qualname__ to a *method* if possible. r����z'Method generated by attrs for class %s.)r����r&���r����rV���r'���r%���r(���)r#����methodr���r���r ���r�������s"����� �z!_ClassBuilder._add_method_dundersN)r%���r&���r'���r(���r����r����r$���r����r����r����r����r����r����r����r����r����r��r��r��r����r���r���r���r ���r����3��s"���:&U " $r����zrThe usage of `cmp` is deprecated and will be removed on or after 2021-06-01. Please use `eq` and `order` instead.c�����������������C���s|���|�dur$t�|du|duf�r$td��|�durDtjttdd��|�|�fS�|du�rP|}|du�r\|}|du�rt|du�rttd��||fS�)z� 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*. Nz&Don't mix `cmp` with `eq' and `order`.������ stacklevelFTz-`order` can only be True if `eq` is True too.)�anyr@����warnings�warn�_CMP_DEPRECATION�DeprecationWarning)r5���r;���r<���Z default_eqr���r���r ���r>������s����r>���c�����������������C���sF���|du�s|du�r|S�|du�r(|du�r(|S�|D�]}t�|�|�r,�dS�q,|S�)a��� 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. auto_detect must be False on Python 2. TFN)rh���)r����flag�auto_detectZdundersr2���Zdunderr���r���r ����_determine_whether_to_implement���s���� r��c��������������������s�����rt�rtd��t|||d�\�� |� t�ttf�r>tj��������������� � ��� ������fdd�}|�du�r||S�||��S�dS�)a/�� A class decorator that adds `dunder <https://wiki.python.org/moin/DunderAlias>`_\ -methods according to the specified attributes using `attr.ib` or the *these* argument. :param these: A dictionary of name to `attr.ib` mappings. This is useful to avoid the definition of your attributes within the class body because you can't (e.g. if you want to add ``__repr__`` methods to Django models) or don't want to. If *these* is not ``None``, ``attrs`` will *not* search the class body for attributes and will *not* remove any attributes from it. If *these* is an ordered dict (`dict` on Python 3.6+, `collections.OrderedDict` otherwise), the order is deduced from the order of the attributes inside *these*. Otherwise the order of the definition of the attributes is used. :type these: `dict` of `str` to `attr.ib` :param str repr_ns: When using nested classes, there's no way in Python 2 to automatically detect that. Therefore it's possible to set the namespace explicitly for a more meaningful ``repr`` output. :param bool auto_detect: Instead of setting the *init*, *repr*, *eq*, *order*, and *hash* arguments explicitly, assume they are set to ``True`` **unless any** of the involved methods for one of the arguments is implemented in the *current* class (i.e. it is *not* inherited from some base class). So for example by implementing ``__eq__`` on a class yourself, ``attrs`` will deduce ``eq=False`` and won't create *neither* ``__eq__`` *nor* ``__ne__`` (but Python classes come with a sensible ``__ne__`` by default, so it *should* be enough to only implement ``__eq__`` in most cases). .. warning:: If you prevent ``attrs`` from creating the ordering methods for you (``order=False``, e.g. by implementing ``__le__``), it becomes *your* responsibility to make sure its ordering is sound. The best way is to use the `functools.total_ordering` decorator. Passing ``True`` or ``False`` to *init*, *repr*, *eq*, *order*, *cmp*, or *hash* overrides whatever *auto_detect* would determine. *auto_detect* requires Python 3. Setting it ``True`` on Python 2 raises a `PythonTooOldError`. :param bool repr: Create a ``__repr__`` method with a human readable representation of ``attrs`` attributes.. :param bool str: Create a ``__str__`` method that is identical to ``__repr__``. This is usually not necessary except for `Exception`\ s. :param Optional[bool] eq: If ``True`` or ``None`` (default), add ``__eq__`` and ``__ne__`` methods that check two instances for equality. They compare the instances as if they were tuples of their ``attrs`` attributes if and only if the types of both classes are *identical*! :param Optional[bool] order: If ``True``, add ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` methods that behave like *eq* above and allow instances to be ordered. If ``None`` (default) mirror value of *eq*. :param Optional[bool] cmp: Setting to ``True`` is equivalent to setting ``eq=True, order=True``. Deprecated in favor of *eq* and *order*, has precedence over them for backward-compatibility though. Must not be mixed with *eq* or *order*. :param Optional[bool] hash: If ``None`` (default), the ``__hash__`` method is generated according how *eq* and *frozen* are set. 1. If *both* are True, ``attrs`` will generate a ``__hash__`` for you. 2. If *eq* is True and *frozen* is False, ``__hash__`` will be set to None, marking it unhashable (which it is). 3. If *eq* is False, ``__hash__`` will be left untouched meaning the ``__hash__`` method of the base class will be used (if base class is ``object``, this means it will fall back to id-based hashing.). Although not recommended, you can decide for yourself and force ``attrs`` to create one (e.g. if the class is immutable even though you didn't freeze it programmatically) by passing ``True`` or not. Both of these cases are rather special and should be used carefully. See our documentation on `hashing`, Python's documentation on `object.__hash__`, and the `GitHub issue that led to the default \ behavior <https://github.com/python-attrs/attrs/issues/136>`_ for more details. :param bool init: Create a ``__init__`` method that initializes the ``attrs`` attributes. Leading underscores are stripped for the argument name. If a ``__attrs_post_init__`` method exists on the class, it will be called after the class is fully initialized. :param bool slots: Create a `slotted class <slotted classes>` that's more memory-efficient. Slotted classes are generally superior to the default dict classes, but have some gotchas you should know about, so we encourage you to read the `glossary entry <slotted classes>`. :param bool frozen: Make instances immutable after initialization. If someone attempts to modify a frozen instance, `attr.exceptions.FrozenInstanceError` is raised. .. note:: 1. This is achieved by installing a custom ``__setattr__`` method on your class, so you can't implement your own. 2. True immutability is impossible in Python. 3. This *does* have a minor a runtime performance `impact <how-frozen>` when initializing new instances. In other words: ``__init__`` is slightly slower with ``frozen=True``. 4. If a class is frozen, you cannot modify ``self`` in ``__attrs_post_init__`` or a self-written ``__init__``. You can circumvent that limitation by using ``object.__setattr__(self, "attribute_name", value)``. 5. Subclasses of a frozen class are frozen too. :param bool weakref_slot: Make instances weak-referenceable. This has no effect unless ``slots`` is also enabled. :param bool auto_attribs: If ``True``, collect `PEP 526`_-annotated attributes (Python 3.6 and later only) from the class body. In this case, you **must** annotate every field. If ``attrs`` encounters a field that is set to an `attr.ib` but lacks a type annotation, an `attr.exceptions.UnannotatedAttributeError` is raised. Use ``field_name: typing.Any = attr.ib(...)`` if you don't want to set a type. If you assign a value to those attributes (e.g. ``x: int = 42``), that value becomes the default value like if it were passed using ``attr.ib(default=42)``. Passing an instance of `Factory` also works as expected. Attributes annotated as `typing.ClassVar`, and attributes that are neither annotated nor set to an `attr.ib` are **ignored**. .. _`PEP 526`: https://www.python.org/dev/peps/pep-0526/ :param bool kw_only: Make all attributes keyword-only (Python 3+) in the generated ``__init__`` (if ``init`` is ``False``, this parameter is ignored). :param bool cache_hash: Ensure that the object's hash code is computed only once and stored on the object. If this is set to ``True``, hashing must be either explicitly or implicitly enabled for this class. If the hash code is cached, avoid any reassignments of fields involved in hash code computation or mutations of the objects those fields point to after object creation. If such changes occur, the behavior of the object's hash code is undefined. :param bool auto_exc: If the class subclasses `BaseException` (which implicitly includes any subclass of any exception), the following happens to behave like a well-behaved Python exceptions class: - the values for *eq*, *order*, and *hash* are ignored and the instances compare and hash by the instance's ids (N.B. ``attrs`` will *not* remove existing implementations of ``__hash__`` or the equality methods. It just won't add own ones.), - all attributes that are either passed into ``__init__`` or have a default value are additionally available as a tuple in the ``args`` attribute, - the value of *str* is ignored leaving ``__str__`` to base classes. :param bool collect_by_mro: Setting this to `True` fixes the way ``attrs`` collects attributes from base classes. The default behavior is incorrect in certain cases of multiple inheritance. It should be on by default but is kept off for backward-compatability. See issue `#428 <https://github.com/python-attrs/attrs/issues/428>`_ for more details. :param Optional[bool] getstate_setstate: .. note:: This is usually only interesting for slotted classes and you should probably just set *auto_detect* to `True`. If `True`, ``__getstate__`` and ``__setstate__`` are generated and attached to the class. This is necessary for slotted classes to be pickleable. If left `None`, it's `True` by default for slotted classes and ``False`` for dict classes. If *auto_detect* is `True`, and *getstate_setstate* is left `None`, and **either** ``__getstate__`` or ``__setstate__`` is detected directly on the class (i.e. not inherited), it is set to `False` (this is usually what you want). :param on_setattr: A callable that is run whenever the user attempts to set an attribute (either by assignment like ``i.x = 42`` or by using `setattr` like ``setattr(i, "x", 42)``). It receives the same arguments as validators: the instance, the attribute that is being modified, and the new value. If no exception is raised, the attribute is set to the return value of the callable. If a list of callables is passed, they're automatically wrapped in an `attr.setters.pipe`. :param Optional[callable] field_transformer: A function that is called with the original class object and all fields right before ``attrs`` finalizes the class. You can use this, e.g., to automatically add converters or validators to fields based on their types. See `transform-fields` for more details. .. 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* z-auto_detect only works on Python 3 and later.Nc��������������������s���t�|�dd��d�u�rtd���p"t|��}�du�o4t|�t�}�oBt|�d�}|rT|rTtd��t|���|�t|���d�d�����|��|��}t|���d�r�|� ����du�r�|� ���t|���d �}|s�|du�r�|����|s�t|�� �d �r�|����|� ���� d�u��r�du��rt|�d��rd}n� }|du�rB|du�rB|d�u�rBtd ��n||du��sf|d�u��r`|du��sf|�rv��r�td��nH|du��s�|d�u��r�|du��r�|du��r�|����n��r�td��|����t|�� �d��r�|����n��r�td��|���S�)Nr���z(attrs only works with new-style classes.Tr����z/Can't freeze a class with a custom __setattr__.)r����r����r����r����)r����r���)r��r��r��r ��r����Fr1���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.)r/���r?����_has_frozen_base_class� issubclassr����rh���r@���r����r��r����r����r��r��r��r����r����r����r����)r���� is_frozenr����Zhas_own_setattrZbuilderr;���r6����r����r���auto_excr����r����Zeq_r����r����r����Zhash_r7���r:���r=���Zorder_r4����repr_nsr����r_���r����r����r���r ����wrap���s��������� ������$� ��� �� �zattrs.<locals>.wrap)r ���r���r>���rC���rD���rE���r���rF���)Z maybe_clsr����r"��r4���r5���r6���r7���r����r����r����r_���r����r:���r����r!��r;���r<���r��r����r����r=���r����r#��r���r ��r ���r]������s�������� 2kr]���c�����������������C���s"���t�|�jdd�tjko |�jjtjkS�)�b Check whether *cls* has a frozen ancestor by looking at its __setattr__. r&���N)r/���r����r����r&���r%���r���r���r���r ���r��x��s ������r��c�����������������C���s ���|�j�tkS�)r$��)r����r����r���r���r���r ���r�����s����c��������������������s���t���fdd�|D���S�)z: Create a tuple of all values of *obj*'s *attrs*. c�����������������3���s���|�]}t���|j�V��qd�S�r���)r/���ru���r������objr���r ���r�������r����z"_attrs_to_tuple.<locals>.<genexpr>r����)r&��r]���r���r%��r ����_attrs_to_tuple���s����r'��c�����������������C���sl���t����}d}d}d�||�jt|�d|�j�|�}ddt|�f|f}tj� ||�|krT|S�|d7�}d�|�}qdS�)zF Create a "filename" suitable for a function being generated. r+���r���z <attrs generated {0} {1}.{2}{3}>r'���Nz-{0}) �uuidZuuid4rO���r&���r/���r%���r_���� linecache�cache� setdefault)r���Z func_nameZ unique_idZextra�count�unique_filenameZ cache_liner���r���r ����_generate_unique_filename���s"����� ��r.��c��������������������s>��t�dd����D�����d}t|�d�}t|��d}d�d�|sB|d7�}n$tsN|d 7�}|d 7�}d����d7��|g�������fd d�}|r��|dt����|r�|dt�|d�����|d�d���n|dt�|d�����|dt����n |d|��d���}i�} i�} t||d�}t|| | ��t |�d�|� d�|ftj|<�| d�S�)Nc�����������������s���s0���|�](}|j�d�u�s$|j�du�r|jd�u�r|V��qdS�)TN)r6���r;���r����r���r���r ���r�������s���z_make_hash.<locals>.<genexpr>z r6���zdef __hash__(selfzhash((z))z):z, *zC, _cache_wrapper=__import__('attr._make')._make._CacheHashWrapper):z_cache_wrapper(�)c��������������������sT������||����|d�f��g����D�]}��|d|j����q$��|d�����dS�)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 z %d,� self.%s,� N)�extendrQ���ru���)�prefix�indentrg����r]���Zclosing_bracesZ hash_funcZmethod_linesZ type_hashr���r ����append_hash_computation_lines���s���� ��z1_make_hash.<locals>.append_hash_computation_lineszif self.%s is None:zobject.__setattr__(self, '%s', ����z self.%s = zreturn self.%szreturn rM���rN���Tr����) rE���r.��r6���r ���rQ���r����rV���rU���rT���r����� splitlinesr)��r*��)r���r]���r����r����Ztabr-��Zhash_defr6���scriptrZ����locs�bytecoder���r5��r ���r�������sV����� ��� � r����c�����������������C���s���t�|�|ddd�|�_|�S�)z% Add a hash method to *cls*. Fr����)r����r�����r���r]���r���r���r ���� _add_hash��s����r=��c������������������C���s���dd��}�|�S�)z Create __ne__ method. c�����������������S���s���|���|�}|tu�rtS�|�S�)zj Check equality and either forward a NotImplemented or return the result negated. )r�����NotImplemented)r#����other�resultr���r���r ���r�����s���� z_make_ne.<locals>.__ne__r���)r���r���r���r ���r����s����r��c����������� ������C���s����dd��|D��}t�|�d�}g�d�}|rr|�d��dg}|D�](}|�d|jf���|�d|jf���q8||d g�7�}n |�d ��d�|�}i�}i�}t||d�} t| ||��t|�d |�d�|ftj |<�|d�S�)z6 Create __eq__ method for *cls* with *attrs*. c�����������������S���s���g�|�]}|j�r|�qS�r���)r;���r����r���r���r ���r����"��r����z_make_eq.<locals>.<listcomp>r;���)zdef __eq__(self, other):z- if other.__class__ is not self.__class__:z return NotImplementedz return (z ) == (r0��z other.%s,z )z return TruerM���rN���NTr����) r.��rQ���ru���rV���rU���rT���r����r8��r)��r*��) r���r]���r-���linesZothersrg���r9��rZ���r:��r;��r���r���r ���r����s,���� � r��c��������������������sV���dd����D������fdd���fdd�}�fdd�}�fd d �}�fdd�}||||fS�) z9 Create ordering methods for *cls* with *attrs*. c�����������������S���s���g�|�]}|j�r|�qS�r���)r<���r����r���r���r ���r����L��r����z_make_order.<locals>.<listcomp>c��������������������s ���t�|����S�)z& Save us some typing. )r'��r%���r]���r���r ����attrs_to_tupleN��s����z#_make_order.<locals>.attrs_to_tuplec��������������������s ���|j�|�j�u�r��|����|�k�S�tS���1 Automatically created by attrs. �r���r>���r#���r?���rC��r���r ���r��T��s����z_make_order.<locals>.__lt__c��������������������s ���|j�|�j�u�r��|����|�kS�tS�rD��rF��rG��rH��r���r ���r��]��s����z_make_order.<locals>.__le__c��������������������s ���|j�|�j�u�r��|����|�kS�tS�rD��rF��rG��rH��r���r ���r��f��s����z_make_order.<locals>.__gt__c��������������������s ���|j�|�j�u�r��|����|�kS�tS�rD��rF��rG��rH��r���r ���r ��o��s����z_make_order.<locals>.__ge__r���)r���r]���r��r��r��r ��r���)r]���rC��r ���r ��H��s���� r ��c�����������������C���s&���|du�r|�j�}t|�|�|�_t��|�_|�S�)z5 Add equality methods to *cls* with *attrs*. N)rq���r��r����r��r���r<��r���r���r ����_add_eq{��s ����rI��c��������������������s$���t�dd��|�D��������fdd�}|S�)z^ Make a repr method that includes relevant *attrs*, adding *ns* to the full name. c�����������������s���s2���|�]*}|j�d�ur|j|j�du�r"t�n|j�fV��qdS�)FTN)r4���ru���r����r���r���r ���r�������s��� �z_make_repr.<locals>.<genexpr>c����������� ��� ������s��z t�j}W�n�ty(���t��}|t�_Y�n0�t|��|v�r:dS�|�j}�du�rvt|dd�}|durn|�dd�d�}q�|j}n�d�|j�}|� t|����zh|dg}d }��D�]8\}}|r�d }n |� d��|�|d|t|�|t��f��q�d � |�d�W�|�t|����S�|�t|����0�dS�)rE��z...Nr'���z>.r���rp���r�����(TFr�����=r+���r/��)�_already_repring�working_setr����rw����idr���r/����rsplitr%���ry���rQ���r2��r!���rV����remove) r#���rM��Zreal_clsr����� class_namer@���firstru���Z attr_repr�Zattr_names_with_reprsr����r���r ���r$������s:���� ��z_make_repr.<locals>.__repr__r����)r]���r����r$���r���rS��r ���r�������s �����*r����c�����������������C���s���|du�r|�j�}t||�|�_|�S�)z% Add a repr method to *cls*. N)rq���r����r$���)r���r����r]���r���r���r ���� _add_repr���s����rT��c�����������������C���s8���t�|��std��t|�dd�}|du�r4tdj|�d���|S�)a��� Return the tuple of ``attrs`` attributes for a class. The tuple also allows accessing the fields by their names (see below for examples). :param type cls: Class to introspect. :raise TypeError: If *cls* is not a class. :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs`` class. :rtype: tuple (with name accessors) of `attr.Attribute` .. versionchanged:: 16.2.0 Returned tuple allows accessing the fields by name. �Passed object must be a class.rq���N�({cls!r} is not an attrs-decorated class.r���)r���r?���r/���r���rO���r<��r���r���r ����fields���s���� �rW��c�����������������C���sF���t�|��std��t|�dd�}|du�r4tdj|�d���tdd��|D���S�)a8�� Return an ordered dictionary of ``attrs`` attributes for a class, whose keys are the attribute names. :param type cls: Class to introspect. :raise TypeError: If *cls* is not a class. :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs`` class. :rtype: an ordered dict where keys are attribute names and values are `attr.Attribute`\ s. This will be a `dict` if it's naturally ordered like on Python 3.6+ or an :class:`~collections.OrderedDict` otherwise. .. versionadded:: 18.1.0 rU��rq���NrV��r���c�����������������s���s���|�]}|j�|fV��qd�S�r���r����r����r���r���r ���r������r����zfields_dict.<locals>.<genexpr>)r���r?���r/���r���rO���r���r<��r���r���r ����fields_dict���s���� �rX��c�����������������C���sD���t�jdu�rdS�t|�j�D�]&}|j}|dur||�|t|�|j���qdS�)z� Validate all attributes on *inst* that have a validator. Leaves all exceptions through. :param inst: Instance of a class with ``attrs`` attributes. FN)r���Z_run_validatorsrW��r���r3���r/���ru���)�instrg���r����r���r���r ����validate ��s���� rZ��c�����������������C���s ���d|�j�v�S�)Nr����)r����r���r���r���r ����_is_slot_cls��s����r[��c�����������������C���s���|�|v�ot�||���S�)z> Check if the attribute name comes from a slot class. )r[��)Za_namer{���r���r���r ���� _is_slot_attr��s����r\��c �������������� ���C���s��|r|rt�d��|p|} g�} i�}|D�]j}|js:|jtu�r:q$| �|��|||j<�|jd�urn|du�rht�d��d} q$|r~|jtjus�t |j|�r$d} q$t |�d�} t| ||||||| |� \}}}i�}t|| d�}|� t|d���| r�t|d<�t|||��t|�d�|�d�| ftj| <�|d�}||_|S�)Nz$Frozen classes can't use on_setattr.Tr7���rN���)r!���� attr_dictZ_cached_setattrr����)r@���r7���r2���r!���rQ���ru���r=���r���r����r\��r.���_attrs_to_init_scriptrU����updater����rT���r����r8��r)��r*��ri���)r���r]���� post_initr����r����r����r{���r�����has_global_on_setattr�needs_cached_setattrZfiltered_attrsr]��rg���r-��r9��rZ����annotationsr:��r;��r����r���r���r ���r����%��s^���� � � � � � r����c�����������������C���s���d|�|f�S�)zJ Use the cached object.setattr to set *attr_name* to *value_var*. �_setattr('%s', %s)r����rL���Z value_var�has_on_setattrr���r���r ����_setattrn��s����rg��c�����������������C���s���d|�t�|�f�|f�S�)zk Use the cached object.setattr to set *attr_name* to *value_var*, but run its converter first. z_setattr('%s', %s(%s)))�_init_converter_patre��r���r���r ����_setattr_with_converteru��s �����ri��c�����������������C���s���|rt�|�|d�S�d|�|f�S�)zo Unless *attr_name* has an on_setattr hook, use normal assignment. Otherwise relegate to _setattr. T�self.%s = %s)rg��)rL���r����rf��r���r���r ����_assign���s����rk��c�����������������C���s$���|rt�|�|d�S�d|�t|�f�|f�S�)z� Unless *attr_name* has an on_setattr hook, use normal assignment after conversion. Otherwise relegate to _setattr_with_converter. Tzself.%s = %s(%s))ri��rh��re��r���r���r ����_assign_with_converter���s�����rl��c�����������������C���s$���|durd|�}nd}d|�|�|f�S�)z8 Unpack *attr_name* from _kw_only dict. Nz, %sr+���z%s = _kw_only.pop('%s'%s)r���)rL���r2���Zarg_defaultr���r���r ����_unpack_kw_only_py2���s���� �rm��c�����������������C���s,���dg}|��dd��|�D����|d�d�7�}|S�)a��� Unpack all *kw_only_args* from _kw_only dict and handle errors. Given a list of strings "{attr_name}" and "{attr_name}={default}" generates list of lines of code that pop attrs from _kw_only dict and raise TypeError similar to builtin if required attr is missing or extra key is passed. >>> print(" ".join(_unpack_kw_only_lines_py2(["a", "b=42"]))) try: a = _kw_only.pop('a') b = _kw_only.pop('b', 42) except KeyError as _key_error: raise TypeError( ... if _kw_only: raise TypeError( ... ztry:c�����������������s���s ���|�]}d�t�|�d����V��qdS�)r1��rK��N)rm���split)r����argr���r���r ���r�������s����z,_unpack_kw_only_lines_py2.<locals>.<genexpr>a ��except KeyError as _key_error: raise TypeError( '__init__() missing required keyword-only argument: %s' % _key_error ) if _kw_only: raise TypeError( '__init__() got an unexpected keyword argument %r' % next(iter(_kw_only)) ) rM���)r2��rn��)�kw_only_argsrA��r���r���r ����_unpack_kw_only_lines_py2���s���� �� rq��c ��������������������s��g�} |r| ��d��|du�rP|du�r,t} t}qX| ��d����fdd�} ��fdd�}nt} t}g�}g�} g�}i�}dd i}|�D��]L}|jr�|��|��|j}|jd up�|jtj uo�|}|j� d �}t|jt �}|r�|jjr�d}nd}|jd u��r�|�r`t�|j�}|jd u�r6| ��|||d|f��|���t|jf�}|j||<�n| ��| ||d|f��|���|jj||<�nT|jd u�r�| ��||d|f�|���t|jf�}|j||<�n| ��| |d|f�|����n�|jtu�r<|�s<d||f�}|j�r�| ��|��n |��|��|jd u�r&| ��||||���|j|t|jf�<�n| ��| |||����n^|�r8d|f�}|j�r`| ��|��n |��|��| ��d|f���t�|j�}|jd u�r�| ��d||||����| ��d��| ��d|||d�|�d�|����|j|t|jf�<�nB| ��d| |||����| ��d��| ��d| ||d�|�d�|����|jj||<�nb|j�rL| ��|��n |��|��|jd u�r�| ��||||���|j|t|jf�<�n| ��| |||���|jdu�rt|jd u�rt|jd urt|j||<�qt|�r$t|d<�| ��d��|D�]B}d|j�}d|j�}| ��d|||jf���|j||<�|||<��q�|�r4| ��d��|�rh|�rR|�rLd}nd}nd}| ��|td f���|�r�d!�d"d#��|�D���}| ��d$|f���d%�|�}| �r�t�r�t| �| �} |d&|�r�d%ndf�7�}n |d'|�r�d%ndd%�| �f�7�}d(j|| �rd)�| �nd*d+�||fS�),z� Return a script of an initializer for *attrs* and a dict of globals. The globals are expected by the generated script. If *frozen* is True, we cannot set the attributes directly so we use a cached ``object.__setattr__``. z8_setattr = _cached_setattr.__get__(self, self.__class__)Tz_inst_dict = self.__dict__c��������������������s"���t�|����rt|�||�S�d|�|f�S�)N�_inst_dict['%s'] = %s)r\��rg��re���r{���r���r ���� fmt_setter���s���� z)_attrs_to_init_script.<locals>.fmt_setterc��������������������s.���|st�|����rt|�||�S�d|�t|�f�|f�S�)Nz_inst_dict['%s'] = %s(%s))r\��ri��rh��re��rs��r���r ����fmt_setter_with_converter��s������z8_attrs_to_init_script.<locals>.fmt_setter_with_converter�returnN�_r#���r+���Fz(%s)zattr_dict['%s'].defaultz%s=attr_dict['%s'].defaultz %s=NOTHINGzif %s is not NOTHING:r1��zelse:rJ��r/��r���z#if _config._run_validators is True:Z__attr_validator_Z__attr_z %s(self, %s, self.%s)zself.__attrs_post_init__()rd��rr��rj���None�,c�����������������s���s���|�]}|j�rd�|j�V��qdS�)zself.N)r7���ru���r����r���r���r ���r�������r����z(_attrs_to_init_script.<locals>.<genexpr>z BaseException.__init__(self, %s)r����z%s**_kw_onlyz%s*, %sz(def __init__(self, {args}): {lines} z �pass)�argsrA��)rQ���rg��ri��rk��rl��r3���ru���r=���r���r�����lstriprC���r2���rB���� takes_selfr7����_init_factory_patrO���r8���rh��rI���r!���r:���r0���r���r����rV���r ���rq��)r]���r����r����r`��r����r{���r����rb��ra��rA��rt��ru��r{��rp��Zattrs_to_validateZnames_for_globalsrc��rg���rL���rf��Zarg_nameZhas_factoryZ maybe_selfZinit_factory_nameZ conv_namero��Zval_nameZinit_hash_cache�valsr���rs��r ���r^�����sl���� ��������� ��� � ��� ��� � �� ��� ��� � � ���r^��c�������������������@���s`���e�Zd�ZdZdZddd�Zdd��Zedd d ��Ze dd���Z d d��Zdd��Zdd��Z dd��ZdS�)r����aH�� *Read-only* representation of an attribute. 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 *field transformer* hook receives a list of them. :attribute name: The name of the attribute. :attribute inherited: Whether or not that attribute has been inherited from a base class. Plus *all* arguments of `attr.ib` (except for ``factory`` which is only syntactic sugar for ``default=Factory(...)``. .. 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. For the full version history of the fields, see `attr.ib`. )ru���r2���r3���r4���r;���r<���r6���r7���r9���r0���r8���r:���rs���r=���NFc�����������������C���s����t�|| |d�\} }t�|�t�}|d|��|d|��|d|��|d|��|d| ��|d|��|d|��|d |��|d |��|d| r�t| �nt��|d| ��|d |��|d|��|d|��d�S�)NTru���r2���r3���r4���r;���r<���r6���r7���r8���r9���r0���r:���rs���r=���)r>���r����r����r����r ����_empty_metadata_singleton)r#���ru���r2���r3���r4���r5���r6���r7���rs���r9���r0���r8���r:���r;���r<���r=���� bound_setattrr���r���r ���r���� ��s*���� � � zAttribute.__init__c�����������������C���s ���t����d�S�r���r����r����r���r���r ���r����@ ��s����zAttribute.__setattr__c�������������� ������sV���|d�u�r��j�}n��j�d�ur"td����fdd�tjD��}|�f�|��j��j|d�dd�|��S�)Nz8Type annotation and type argument cannot both be presentc��������������������s ���i�|�]}|d�vr|t���|��qS�))ru���r3���r2���r0���rs���r����)r���r�����r����r���r ���r����L ��s �����z0Attribute.from_counting_attr.<locals>.<dictcomp>F)ru���r3���r2���r0���r5���rs���)r0���r@���r����r����� _validator�_default)r���ru���r����r0���Z inst_dictr���r���r ���r����C ��s&���� � ���zAttribute.from_counting_attrc�����������������C���s���t�jttdd��|�jo|�jS�)zD Simulate the presence of a cmp attribute and warn. r7��r��)r��r��r��r��r;���r<���r"���r���r���r ���r5���b ��s����z Attribute.cmpc�����������������K���s���t���|��}|�|�����|S�)z� Copy *self* and apply *changes*. This works similarly to `attr.evolve` but that function does not work with ``Attribute``. It is mainly meant to be used for `transform-fields`. .. versionadded:: 20.3.0 )�copy� _setattrsr����)r#���Zchanges�newr���r���r ���rv���l ��s���� zAttribute.evolvec��������������������s���t���fdd���jD���S�)�( Play nice with pickle. c�����������������3���s*���|�]"}|d�krt���|�nt��j�V��qdS�)r9���N)r/���r����r9���r����r"���r���r ���r����� ��s����z)Attribute.__getstate__.<locals>.<genexpr>)rE���r����r"���r���r"���r ���r����~ ��s�����zAttribute.__getstate__c�����������������C���s���|���t|�j|���dS�)r���N)r���r����r����)r#���r����r���r���r ���r����� ��s����zAttribute.__setstate__c�����������������C���sH���t��|�t�}|D�]2\}}|dkr,|||��q|||r<t|�nt��qd�S�)Nr9���)r����r����r����r ���r���)r#���Zname_values_pairsr���ru���r����r���r���r ���r���� ��s����� �zAttribute._setattrs)NNNFNNN)N)r%���r&���r'���r(���r����r����r����r����r����rS���r5���rv���r����r����r���r���r���r���r ���r�������s&����������� / r����c�����������������C���s,���g�|�]$}t�|td�dd�dd|dkddd� �qS�)NTFr9���) ru���r2���r3���r4���r5���r;���r<���r6���r7���rs����r����r!���r����r���r���r ���r����� ��s��� ��r����rB��c�����������������C���s���g�|�]}|j�d�kr|�qS�rr���r����r����r���r���r ���r����� ��r����c�����������������C���s ���g�|�]}|j�r|jd�kr|�qS�rr���)r6���ru���r����r���r���r ���r����� ��r����c�������������������@���sd���e�Zd�ZdZdZedd��dD���edddddd dd dd d dd �f�ZdZdd ��Z dd��Z dd��ZdS�)rH���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. ) rl���r���r4���r;���r<���r6���r7���r9���r���r8���r0���r:���r=���c�����������������c���s.���|�]&}t�|td�dd�ddddddd�d�V��qd�S�)NTF�ru���r2���r3���r4���r5���r6���r7���r:���r;���r<���rs���r=���r���r����r���r���r ���r����� ��s�����z_CountingAttr.<genexpr>)rl���r���r4���r;���r<���r6���r7���r=���r9���NTFr���r���c�����������������C���sb���t��jd7��_t�j|�_||�_||�_||�_||�_||�_||�_||�_ ||�_ ||�_| |�_| |�_ | |�_d�S�r����)rH����cls_counterrl���r���r���r8���r4���r;���r<���r6���r7���r9���r0���r:���r=���)r#���r2���r3���r4���r5���r6���r7���r8���r9���r0���r:���r;���r<���r=���r���r���r ���r����� ��s����z_CountingAttr.__init__c�����������������C���s$���|�j�du�r||�_�nt|�j�|�|�_�|S�)z� Decorator that adds *meth* to the list of validators. Returns *meth* unchanged. .. versionadded:: 17.1.0 N)r���rG����r#���r��r���r���r ���r3��� ��s���� z_CountingAttr.validatorc�����������������C���s"���|�j�turt���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���r!���r���rB���r���r���r���r ���r2���$ ��s���� z_CountingAttr.default)r%���r&���r'���r(���r����rE���r����rq���r���r����r3���r2���r���r���r���r ���rH���� ��s2�������)rH���)r����r7���r6���c�������������������@���s&���e�Zd�ZdZe��Ze��Zddd�ZdS�)rB���a��� Stores a factory callable. If passed as the default value to `attr.ib`, the factory is used to generate a new value. :param callable factory: A callable that takes either none or exactly one mandatory positional argument depending on *takes_self*. :param bool takes_self: Pass the partially initialized instance that is being initialized as a positional argument. .. versionadded:: 17.1.0 *takes_self* Fc�����������������C���s���||�_�||�_dS�)z� `Factory` is part of the default machinery so if we want a default value here, we have to implement it ourselves. N)rI���r}��)r#���rI���r}��r���r���r ���r����L ��s����zFactory.__init__N)F)r%���r&���r'���r(���rJ���rI���r}��r����r���r���r���r ���rB���9 ��s���rB���c�������������� ���K���s����t�|t�r|}n*t�|ttf�r2tdd��|D���}ntd��|�dd�}t|�||du�rXi�nd|i�}zt�d�j � dd�|_W�n�tt fy����Y�n0�|�d d�}t||� d �|� d�d�\|d <�|d<�tf�d |i|��|�S�)aB�� A quick way to create a new class called *name* with *attrs*. :param str name: The name for the new class. :param attrs: A list of names or a dictionary of mappings of names to attributes. If *attrs* is a list or an ordered dict (`dict` on Python 3.6+, `collections.OrderedDict` otherwise), 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. :type attrs: `list` or `dict` :param tuple bases: Classes that the new class will subclass. :param attributes_arguments: Passed unmodified to `attr.s`. :return: A new class with *attrs*. :rtype: type .. versionadded:: 17.1.0 *bases* .. versionchanged:: 18.1.0 If *attrs* is ordered, the order is retained. c�����������������s���s���|�]}|t���fV��qd�S�r���)rJ���r����r���r���r ���r����q ��r����zmake_class.<locals>.<genexpr>z(attrs argument must be a dict or a list.r����Nr���r%����__main__r5���r;���r<���Tr����)rC���r����rD���rE���r?����popr0����sys� _getframe� f_globalsr����r&���r����r@���r>���r����)ru���r]����basesZattributes_argumentsZcls_dictr`���type_r5���r���r���r ���� make_classU ��s8���� � � ��r���)r����r6���c�������������������@���s���e�Zd�ZdZe��Zdd��ZdS�)� _AndValidatorz2 Compose many validators to a single one. c�����������������C���s���|�j�D�]}||||��qd�S�r���)�_validators)r#���rY��re���r����r����r���r���r ����__call__� ��s���� z_AndValidator.__call__N)r%���r&���r'���r(���rJ���r���r���r���r���r���r ���r���� ��s���r���c������������������G���s6���g�}|�D�] }|��t|t�r |jn|g��qtt|��S�)z� A validator that composes multiple validators into one. When called on a value, it runs all wrapped validators. :param callables validators: Arbitrary number of validators. .. versionadded:: 17.1.0 )r2��rC���r���r���rE���)Z validatorsr��r3���r���r���r ���rG���� ��s���� ��rG���c���������������������s�����fdd�}|S�)z� A converter that composes multiple converters into one. When called on a value, it runs all wrapped converters, returning the *last* value. :param callables converters: Arbitrary number of converters. .. versionadded:: 20.1.0 c��������������������s�����D�]}||��}�q|�S�r���r���)r ��r8����� convertersr���r ����pipe_converter� ��s���� zpipe.<locals>.pipe_converterr���)r���r���r���r���r ���rF���� ��s����rF���)T)NNNNNNNFFTFFFFFNNFFNNN)N)NN)N)`Z __future__r���r���r���r���r)��r���� threadingr(��r���operatorr���r+���r���r���Z_compatr ���r ���r���r���r ���r���r���� exceptionsr���r���r���r���r���r����r����r����rh��r~��rR���ra���r����r���rc���r���r!����intr*���rJ���r[���r\���rb���rh���rj���ro���r}���r~���r����r����r����r����r��r>���r��r]���r����r��r'��r.��r����r=��r��r��r ��rI���localrL��r����rT��rW��rX��rZ��r[��r\��r����rg��ri��rk��rl��rm��rq��r^��r����r����Z_arH���rB���r���r���rG���rF���r���r���r���r ����<module>���s��$ �� �2� k ������ ����������������������� ��| P*3 ; I )���6 � �� �D