e#ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZmZddl mZmZmZmZddlmZmZmZmZej4ZdZdZd Zd Zej@iZ!eZ"ejFejHejJZ&Gd d ejNZ(e(jRZ) Gd de*Z+e)ddddddddddddddfdZ,dOdZ-dZ.dZ/e/dgdZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9Gd d!Z:d"Z;d#Z< dPd$Z= dQd%Z>e>Z? d&Z@d'ZAd(ZBd)ZCd*ZDd+ZEd,ZFdRd-ZGd.ZHdSd/ZId0ZJd1ZKd2Z%d3ZLd4ZMd5ZNd6ZOd7ZPd8ZQd9ZRd:ZSd;eTdd?ZVeVjDcgc]}eV|e)ddddd|d@k7ddeU|A  c}ZXeCeGeIeVeXBeXDcgc]}|jdCk7s|c}BeXDcgc]!}|js|jdCk7s |#c}BZVGdDdEZ[eGeIe[Z[GdFdGZ\e\jDcgc]}eV|e)ddddddddH c}Z]eCeGeIe\e]Be]Be]BZ\efdfdIZ^e>ddJGdKdLZ_dMZ`dNZ#ycc}wcc}wcc}wcc}w)TN) itemgetter)_compat_configsetters)PY310 PY_3_8_PLUS_AnnotationExtractorget_generic_base)DefaultAlreadySetErrorFrozenInstanceErrorNotAnAttrsClassErrorUnannotatedAttributeErrorz__attr_converter_%sz__attr_factory_%s)ztyping.ClassVarz t.ClassVarClassVarztyping_extensions.ClassVar_attrs_cached_hashc>eZdZdZej ZdZdZy)_NothingaH 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. cy)NNOTHINGselfs ,/usr/lib/python3/dist-packages/attr/_make.py__repr__z_Nothing.__repr__Escy)NFrrs r__bool__z_Nothing.__bool__HsrN) __name__ __module__ __qualname____doc__enumautorrrrrrrr8s diikGrrc(eZdZdZeddfdZy)_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. Nrc ||fSNr)r_none_constructor_argss r __reduce__z_CacheHashWrapper.__reduce__^s  %''r)rrr r!typer*rrrr%r%Rs ,0:R(rr%TFct|| | d\} }} }||dur|dur d}t|| 8|tur d}t|t | s d}t|t | }|i}t | ttfrtj| } |rt |ttfrt|}|rt |ttfrt|}tdid|d|d |d dd |d |d |d|d|d| d| d|d| d|d| d|S)a Create a new attribute on a class. .. warning:: Does *not* do anything unless the class is also decorated with `attr.s` / `attrs.define` / and so on! Please consider using `attrs.field` in new code (``attr.ib`` will *never* go away, though). :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 `attrs.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 `attrs.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. .. seealso:: `defaults` :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 :func:`~attrs.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 `attrs.validators.get_disabled` / `attrs.validators.set_disabled`. The validator can also be set using decorator notation as shown below. .. seealso:: :ref:`validators` :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 eq: If ``True`` (default), include this attribute in the generated ``__eq__`` and ``__ne__`` methods that check two instances for equality. To override how the attribute value is compared, pass a ``callable`` that takes a single value and returns the value to be compared. .. seealso:: `comparison` :type eq: a `bool` or a `callable`. :param order: If ``True`` (default), include this attributes in the generated ``__lt__``, ``__le__``, ``__gt__`` and ``__ge__`` methods. To override how the attribute value is ordered, pass a ``callable`` that takes a single value and returns the value to be ordered. .. seealso:: `comparison` :type order: a `bool` or a `callable`. :param cmp: Setting *cmp* is equivalent to setting *eq* and *order* to the same value. Must not be mixed with *eq* or *order*. .. seealso:: `comparison` :type cmp: a `bool` or a `callable`. :param bool | None 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*. .. seealso:: `hashing` :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. .. seealso:: `init` :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. .. seealso:: :ref:`converters` :param dict | None metadata: An arbitrary mapping, to be used by third-party components. See `extending-metadata`. :param type: The type of the attribute. Nowadays, the preferred method to specify the type is using a variable annotation (see :pep:`526`). 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 `. :param bool kw_only: Make this attribute keyword-only 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 `attrs.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 `attrs.setters.NO_OP` :param str | None alias: Override this attribute's parameter name in the generated ``__init__`` method. If left `None`, default to ``name`` stripped of leading underscores. See `private-attributes`. .. versionadded:: 15.2.0 *convert* .. versionadded:: 16.3.0 *metadata* .. versionchanged:: 17.1.0 *validator* can be a ``list`` now. .. versionchanged:: 17.1.0 *hash* is ``None`` and therefore mirrors *eq* by default. .. versionadded:: 17.3.0 *type* .. deprecated:: 17.4.0 *convert* .. versionadded:: 17.4.0 *converter* as a replacement for the deprecated *convert* to achieve consistency with other noun-based arguments. .. versionadded:: 18.1.0 ``factory=f`` is syntactic sugar for ``default=attr.Factory(f)``. .. versionadded:: 18.2.0 *kw_only* .. versionchanged:: 19.2.0 *convert* keyword argument removed. .. versionchanged:: 19.2.0 *repr* also accepts a custom callable. .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01. .. versionadded:: 19.2.0 *eq* and *order* .. versionadded:: 20.1.0 *on_setattr* .. versionchanged:: 20.3.0 *kw_only* backported to Python 2 .. versionchanged:: 21.1.0 *eq*, *order*, and *cmp* also accept a custom callable .. versionchanged:: 21.1.0 *cmp* undeprecated .. versionadded:: 22.2.0 *alias* TNF6Invalid value for hash. Must be True, False, or None.z=The `default` and `factory` arguments are mutually exclusive.z*The `factory` argument must be a callable.default validatorreprcmphashinit convertermetadatar+kw_onlyeqeq_keyorder order_key on_setattraliasr) _determine_attrib_eq_order TypeErrorr ValueErrorcallableFactory isinstancelisttuplerpipeand_ _CountingAttr)r.r/r0r1r2r3r5r+r4factoryr6r7r9r;r<r8r:msgs rattribrJbsF$> R$ By D,U1BFn ' !O S/ ! >CS/ !'"*tUm,\\:. Z D%=9)$ Z D%=9)$                         ! rc8t||d}t|||y)zU "Exec" the script with the given global (globs) and local (locs) variables. execN)compileeval)scriptglobslocsfilenamebytecodes r_compile_and_evalrT9svx0H5$rci}d}|} t|d|jd|f}tjj ||}||k(rn|ddd|d}|dz }Ut ||||||S)zO Create the method with the script given and return the method object. rTN->)len splitlines linecachecache setdefaultrT) namerOrRrPrQcount base_filenamelinecache_tupleold_vals r _make_methodrcAs D EM  K    d #    //,,XG o % #CR()5'3   feT84 :rc|d}d|ddg}|r,t|D]\}}|jd|d|dn|jdttd }t d j ||||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)) Attributeszclass z(tuple):z __slots__ = () z% = _attrs_property(_attrs_itemgetter())z pass)_attrs_itemgetter_attrs_property ) enumerateappendrpropertyrTjoin)cls_name attr_namesattr_class_nameattr_class_templatei attr_namerPs r_make_attr_tuple_classru^s" *-O !*%j1 LAy  & &yk!FqcL   "":.", JEdii 34e<  !!r _Attributes)attrs base_attrsbase_attrs_mapct|}|jdr|jdr|dd}|jtS)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. )'"rrV)str startswithendswith_classvar_prefixes)annots r _is_class_varrsE JE  #z(Ba    . //rct||t}|tury|jddD]}t||d}||usyy)zR Check whether *cls* defines *attrib_name* (and doesn't just inherit it). FrNT)getattr _sentinel__mro__)cls attrib_nameattrbase_clsas r_has_own_attributersS 3 Y /D yKKO Hk4 0 19 rc6t|dr |jSiS)z$ Get annotations for *cls*. __annotations__)rrrs r_get_annotationsrs #01""" Ircg}i}t|jddD]a}t|dgD]O}|js|j|vr|j d}|j ||||j<Qcg}t}t|D]>}|j|vr|jd||j|j@||fS)zQ Collect attr.ibs from base classes of *cls*, except *taken_attr_names*. rrV__attrs_attrs__T inheritedr) reversedrrrr^evolverlsetinsertadd)rtaken_attr_namesrx base_attr_maprrfilteredseens r_collect_base_attrsrsJMS[[2./-#4b9 -A{{aff(884(A   a $,M!&& !  --H 5D j ! 66T> 1   ] ""rcg}i}|jddD]p}t|dgD]^}|j|vr|jd}|j |j|j ||||j<`r||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. rrVrTr)rrr^rrrl)rrrxrrrs r_collect_base_attrs_brokenrsJMKK"%-#4b9 -Avv))4(A   (   a $,M!&& ! -- } $$rc |jt|}|t|j}n3|dur jD chc]\}} t | t r|} }} g}t } |jD]y\} } t| r| j| j| t}t |t s|tur tn t|}|j| |f{| | z }t|dkDrQtddjt!|fdzdzt!d jDd }|D cgc],\} }t"j%| ||j|  .}} }|r(t'||Dchc]}|j(c}\}}n't+||Dchc]}|j(c}\}}|r>|Dcgc]}|j-d }}|Dcgc]}|j-d }}||z}d }d|DD]B}|dur"|j.turd|}t1||d us.|j.tusAd}D| |||}|Dcgc]5}|j2s%|j-t5|j(n|7}}|Dcgc]}|j(}}t7|j8|}t;||||fScc} }wcc}} wcc}wcc}wcc}wcc}wcc}wcc}w)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`. Tr.rz1The following `attr.ib`s lack a type annotation: , c:j|jSr')getcounter)ncds rz"_transform_attrs..sbffQi6G6Gr)key.c3JK|]\}}t|tr||fywr')rBrG).0r^rs r z#_transform_attrs..s* D$dM2t  s!#c |djSNr)r)es rrz"_transform_attrs.."s!A$,,r)r^car+)r6Fc3\K|]$}|jdus|jdus!|&yw)FN)r3r6rrs rrz#_transform_attrs..@s& MA!&&"5!))u:La Ms ,,,zlNo mandatory attributes allowed after an attribute with a default value or factory. Attribute in question: )r<)__dict__rrCitemsrBrGrrrrrrJrlrYrrnsorted Attributefrom_counting_attrrr^rrr.r?r<_default_init_alias_forrurrv)rthese auto_attribsr6collect_by_mrofield_transformerannsca_listr^rca_names annot_namesrtr+r unannotatedr own_attrsrxrrw had_defaultrIrp AttrsClassrs @r_transform_attrsrs_ B C D u{{}%  !hhj d$ .   e #zz| +OItT" OOI &y'*Aa/ !W FH&2C NNIq> * +, { a +C));,GH   "$((*  '  %  Ir $$r(; % I$7 ),Q!&&,% ! M%? ),Q!&&,% ! M5>?QXXdX+? ?6@Aahhth,A A  "E K M M $ 199#7ABCAFGCS/ ! % AIIW$<K $!#u-  @Aww.qvv67AM E #((Q!&&(J(' jAJ  5):}E FFo H--@A. )s0L.1L.L" L' 9L,L1:L6L;cgd}||jdn|jgd|jddgt|d}|tj||d}t dd j |||S) N) zdef wrapper():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, if hasattr(super(), '__getattr__'):z. 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()r)cached_properties_cached_setattr_get_clsoriginal_getattr __getattr__rj)rlextend_generate_unique_filename _obj_setattr__get__rcrn)rrrlinesunique_filenameglobs r_make_cached_property_getattrr[s E# :      LL $ % 0Y?O/+33,  D  %  rcnt|tr|dvrtj|||yt)z4 Attached to frozen classes as __setattr__. ) __cause__ __context__ __traceback__N)rB BaseException __setattr__r rr^values r_frozen_setattrsrs:$ &44, !!$e4  rct)z4 Attached to frozen classes as __delattr__. r )rr^s r_frozen_delattrsrs   rceZdZdZdZdZdZerddlZdZ ndZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZy) _ClassBuilderz( Iteratively build *one* class. ) _attr_names_attrs_base_attr_map _base_names _cache_hashr _cls_dict_delete_attribs_frozen _has_pre_init_pre_init_has_args_has_post_init_is_exc _on_setattr_slots _weakref_slot_wrote_own_setattr_has_custom_setattrct||||| |\}}}||_|rt|jni|_||_|Dchc]}|j c}|_||_td|D|_ ||_ ||_ ||_ | |_tt!|dd|_d|_|j"r>|j&}t)j*|}t-|j.dkD|_tt!|dd|_t| |_| |_| |_| |_d|_|j |jd<|r.t<|jd<t>|jd<d |_n| t@tBjDtBjFfvrldx}}|D]%}|jHd }|jJd }|s"|s%n| t@k(r|s|r*| tBjDk(r|r| tBjFk(r |sd|_|r.|jM\|jd <|jd <yycc}w) Nc34K|]}|jywr'r^rs rrz)_ClassBuilder.__init__..s 7A 7s__attrs_pre_init__Fr__attrs_post_init__rr __delattr__T __getstate__ __setstate__)'rrdictrrrr^rrrDrrrrrboolrrrrinspect signaturerY parametersrrrrrrrr_ng_default_on_setattrrvalidateconvertr/r4_make_getstate_setstate)rrrslotsfrozen weakref_slotgetstate_setstaterr6 cache_hashis_excrr;has_custom_setattrrrwrxbase_mapr pre_init_funcpre_init_signature has_validator has_converters r__init__z_ClassBuilder.__init__sJ"'7       ' #z8 /4cll+" ,67qAFF7& 7 77  )%!'#/CU"KL"'    22M!(!2!2=!A &)*<*G*G&H1&LD #"730Eu#MN#'; %#5 "',0KK() ,)rrrs rrz_ClassBuilder.__repr__s$TYY%7%7$8;;rrNc|jdur|jS|jj|j Sz Finalize class based on the accumulated configuration. Builder cannot be used after calling this method. T)r_create_slots_classabcupdate_abstractmethods_patch_original_classrs r build_classz_ClassBuilder.build_class%sB {{d"//118822**, rc^|jdur|jS|jSr)rrrrs rrz_ClassBuilder.build_class4s. {{d"//11--/ /rc|j}|j}|jr\|jD]M}||vst ||t t us t jt5t||dddO|jjD]\}}t||||js+t |ddrd|_|js t |_|S#1swYxYw)zA Apply accumulated methods and return the class. N__attrs_own_setattr__F)rrrrrr contextlibsuppressAttributeErrordelattrrrsetattrrrrrr)rr base_namesr^rs rrz#_ClassBuilder._patch_original_class?sii%%    (( + *T95YF $,,^<+T*++ + >>//1 &KD% Cu % & &&7 (%, ).C %++". #++s * C))C2 c |jjDcic]&\}}|gt|jddvr||(}}}|jsSd|d<|j sB|j jD])}|jjdds t|d<ni}d}|j jddD]U}|jjddd }|jt|d gDcic]}|t||c}Wt|j}|j} |j r$dt|j d d vr d| vr|s| d z } t"rH|jD cic],\}} t%| t&j(r || j*.} }} ni} g} | r| t| j-z } | D]}||=t/|j } | jD]F\}}t1j2|j4}|t0j6j8usB|| |<H|jd }|| j;|t=| ||j |d <| Dcgc] }||vs| }}|jDcic] \}}||vr||}}}|Dcgc] }||vs| }}|j||j>r|j;t@t||d <|j jB|d<tE|j |j jF|j j|}tIjJ|jjM| D]}t%|tNtPfrt|jRdd}n5t%|tTrt|jVdd}n t|dd}|si|D]%} |jX|j u}|s||_,'|Scc}}wcc}wcc} }wcc}wcc}}wcc}w#tZ$rYXwxYw)zL Build and return a new class with a `__slots__` attribute. r __weakref__FrrrrVNT __slots__r)r%rr __closure__).rrrDrrrr __bases__rrrrupdaterrrrr rB functoolscached_propertyfunckeysrrrreturn_annotation Parameteremptyrlrr_hash_cache_fieldr r+r itertoolschainvalues classmethod staticmethod__func__rmfget cell_contentsr?)rkvrrexisting_slotsweakref_inheritedr^r#namesr+r&additional_closure_functions_to_updateclass_annotationsr, annotationr slot_namesslotslot_descriptor reused_slotsritem closure_cellscellmatchs rrz!_ClassBuilder._create_slots_classcs ,,. 1M% 0 01M:M}MM qD  &&*/B& '++ $ 3 3H((,,-DeL,8=)! ))!B/ H  $$]D9E$(!  ! !!(+r B'(D11  ))*      WTYY R%HHU*% % %E .0XXZ!)D/oy/H/HIo***! !!# 24.  U,1134 4E) tH !1 ; /557 9 d$..t4FF W%6%6%<%<<.8%d+ 9 "vvm4 +6==>NO =!#3TYY!B}  (-GtJ0FdG G*8)=)=)? %oz! / !  (2NtT5MdN N ,      / 0 +;!YY33>d499odii00$))2E2ErJOO LL   !#I  1D$l ;<!( }d K D(+!( =$ G 'mT B  % 11 ..$));E -0* 1! 12 Y >$!JH  OJ"sA+Q Q 1Q Q%Q>Q Q% Q%!Q** Q65Q6c|jt|j||j|jd<|S)Nr)_add_method_dunders _make_reprrrr)rnss radd_reprz_ClassBuilder.add_reprs6%)%=%= t{{B 2& z" rc|jjd}| d}t|d}|j||jd<|S)Nrz3__str__ can only be generated if a __repr__ exists.c"|jSr'rrs r__str__z&_ClassBuilder.add_str..__str__s==? "rrR)rrr?rK)rr0rIrRs radd_strz_ClassBuilder.add_strsO~~!!*- <GCS/ ! #%)$<$. s! R=-@B! s cDDcic]}|t||c}Scc}w)9 Automatically created by attrs. r)rr^state_attr_namess rslots_getstatez=_ClassBuilder._make_getstate_setstate..slots_getstates&;KK$D'$--K KKsctj|}t|trt |D]\}}|||nD]}||vs||||r|t dyy)rXN)rrrBrDzipr1)rstate_ClassBuilder__bound_setattrr^rhash_caching_enabledrZs rslots_setstatez=_ClassBuilder._make_getstate_setstate..slots_setstates+2248O%'$''7#?1KD%#D%01-;Du}'eDk:;$ 148$r)rDrr)rr[rar`rZs @@rrz%_ClassBuilder._make_getstate_setstatesI !! ))!   L $// 9,~--rc$d|jd<|S)N__hash__)rrs rmake_unhashablez_ClassBuilder.make_unhashable0s%)z" rc|jt|j|j|j|j |j d<|S)Nrr rc)rK _make_hashrrrrrrs radd_hashz_ClassBuilder.add_hash4sH%)%=%=   ||++  & z" rcH|jt|j|j|j|j |j |j|j|j|j|j|jd |jd<|S)NF attrs_initrrK _make_initrrrrrrrrrrrrrs radd_initz_ClassBuilder.add_init@s%)%=%=   ""''##    ##     & z"" rcVtd|jD|jd<y)Nc3dK|](}|jr|js|j*ywr')r3r6r^)rfields rrz/_ClassBuilder.add_match_args..Us)1 zz%-- JJ1 s.0__match_args__)rDrrrs radd_match_argsz_ClassBuilder.add_match_argsTs'+01 1 , '(rcH|jt|j|j|j|j |j |j|j|j|j|j|jd |jd<|S)NTrj__attrs_init__rlrs radd_attrs_initz_ClassBuilder.add_attrs_init[s+/+C+C   ""''##    ##    , '(" rc|j}|jt|j|j|d<|jt |d<|S)N__eq____ne__)rrK_make_eqrr_make_nerrs radd_eqz_ClassBuilder.add_eqosN ^^// TYY , 8 // ;8  rcj}fdtjjD\|d<|d<|d<|d<S)Nc3@K|]}j|ywr')rK)rmethrs rrz*_ClassBuilder.add_order..|s&B   $ $T *B s__lt____le____gt____ge__)r _make_orderrrr|s` r add_orderz_ClassBuilder.add_orderysL ^^B #DIIt{{;B >8 blBxL"X,  rcx|jr|Si|jD]C}|jxs |j}|s |tj us3||f|j <Es|S|jr d}t|fd}d|jd<|j||jd<d|_ |S)Nz7Can't combine custom __setattr__ with on_setattr hooks.ch |\}}||||}t|||y#t$r|}YwxYwr')KeyErrorr)rr^valrhooknvalsa_attrss rrz._ClassBuilder.add_setattr..__setattr__sG *"4.4D!S) tT *   s # 11Trr) rrr;rrNO_OPr^rr?rrKr)rrr;rIrrs @r add_setattrz_ClassBuilder.add_setattrs <<K 1A9)9)9Jj =#$j=  1 K  # #KCS/ ! +37./(,(@(@(M}%"& rctjt5|jj|_dddtjt5|jj d|j |_dddtjt5d|jj d|_ddd|S#1swYxYw#1swYXxYw#1swY|SxYw)zL Add __module__ and __qualname__ to a *method* if possible. Nrz$Method generated by attrs for class )rrr rrr rr!)rmethods rrKz!_ClassBuilder._add_method_dunderss  0 5 $ 4 4F  5  0 P%)YY%;%;$_determine_attrib_eq_order..decide_callable_or_booleans1 E?u3EczCczrFTrr) r1r7r9rrIrcmp_keyr8r:s rr=r=s  3$T0ABC6o 1#6 WGS')) zF/3 F }vy5e<y U{u}=o vui ''rcT|dus|dur|S||dur|S|D]}t||sy|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. TF)r)rflag auto_detectdundersr.dunders r_determine_whether_to_implementrsL t|tu}  | u, c6 * Nrc t|||d\||tttfrt j      fd}||S||S)a4 A class decorator that adds :term:`dunder methods` according to the specified attributes using `attr.ib` or the *these* argument. Please consider using `attrs.define` / `attrs.frozen` in new code (``attr.s`` will *never* go away, though). :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. The order is deduced from the order of the attributes inside *these*. :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 will 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. :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 bool | None 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*! .. seealso:: `comparison` :param bool | None 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*. .. seealso:: `comparison` :param bool | None cmp: Setting *cmp* is equivalent to setting *eq* and *order* to the same value. Must not be mixed with *eq* or *order*. .. seealso:: `comparison` :param bool | None unsafe_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. .. seealso:: - Our documentation on `hashing`, - Python's documentation on `object.__hash__`, - and the `GitHub issue that led to the default \ behavior `_ for more details. :param bool | None hash: Alias for *unsafe_hash*. *unsafe_hash* takes precedence. :param bool init: Create a ``__init__`` method that initializes the *attrs* attributes. Leading underscores are stripped for the argument name. If a ``__attrs_pre_init__`` method exists on the class, it will be called before the class is initialized. If a ``__attrs_post_init__`` method exists on the class, it will be called after the class is fully initialized. If ``init`` is ``False``, an ``__attrs_init__`` method will be injected instead. This allows you to define a custom ``__init__`` method that can do pre-init work such as ``super().__init__()``, and then call ``__attrs_init__()`` and ``__attrs_post_init__()``. .. seealso:: `init` :param bool slots: Create a :term:`slotted class ` 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 :term:`glossary entry `. :param bool frozen: Make instances immutable after initialization. If someone attempts to modify a frozen instance, `attrs.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 ` 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 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 `attrs.Factory` also works as expected in most cases (see warning below). Attributes annotated as `typing.ClassVar`, and attributes that are neither annotated nor set to an `attr.ib` are **ignored**. .. warning:: For features that use the attribute name to create decorators (e.g. :ref:`validators `), you still *must* assign `attr.ib` to them. Otherwise Python will either not find the name or try to use the default value to call e.g. ``validator`` on it. These errors can be quite confusing and probably the most common bug report on our bug tracker. :param bool kw_only: Make all attributes keyword-only 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-compatibility. .. seealso:: Issue `#428 `_ :param bool | None 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 `attrs.setters.pipe`. :type on_setattr: `callable`, or a list of callables, or `None`, or `attrs.setters.NO_OP` :param callable | None 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. .. seealso:: `transform-fields` :param bool match_args: If `True` (default), set ``__match_args__`` on the class to support :pep:`634` (Structural Pattern Matching). It is a tuple of all non-keyword-only ``__init__`` parameter names on Python 3.10 and later. Ignored on older Python versions. .. 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). Ncxs t|} duxrt|t}xr t|d}|r|r d}t |t ||t |d | | }t |dr|jdur|jt | d}|s|dur|j|st |dr|j|jdurt|d rd durd ur d }t|d us|d us|r rKd }t|dus |dur|dur|jn r d }t||jt |d r|jn|j! r d}t|t"rrt|ds|j%|j'S)NTrz/Can't freeze a class with a custom __setattr__.)rrrrQ)rxry)rrrrrcFr-zlInvalid value for cache_hash. To use hash caching, hashing must be either explicitly or implicitly enabled.)rzFInvalid value for cache_hash. To use hash caching, init must be True.rr)_has_frozen_base_class issubclassrrr?rrrNrSr}rrr>rhrdrnrvrrsr)r is_frozenr has_own_setattrrIbuilderr7rrauto_excr req_rrr r2r3r6 match_argsr;order_r0repr_nsrr}rrs rwrapzattrs..wrapHsL94S9 T!Djm&D% *< +  yCCS/ !      +!0          ) , + {M    W % $; OO  , k#7 "* NN 9 &N      Lt#"3 3D t E 1d6FJCC. 5=T\bEkfEn$ T\ LR4ZI,=    En$  # # % * {M       " " $^n$ &s,<=  " " $""$$r)rrBrCrDrrE) maybe_clsrrr0r1r2r3rrrr}rr6r rr7r9rrr r;rr unsafe_hashrrrs ``` `````````` `````` @@rrwrwsuJ ,CUDAKC*tUm,\\:. d%d%d%d%P  ?rc&|jtuS)zV Check whether *cls* has a frozen ancestor by looking at its __setattr__. )rrrs rrrs ??. ..rc Xd|d|jdt|d|jdS)zF Create a "filename" suitable for a function being generated. z.s1AFFdNqvv~!$$$,s 888 r2zdef __hash__(selfzhash((rgz):z, *zC, _cache_wrapper=__import__('attr._make')._make._CacheHashWrapper):z_cache_wrapper()c hj||zz|d dzgD]u}|jrEd|jd}|j|<j|d|d|jdzTj|d|jdzwj|dzzy ) z Generate the code for actually computing the hash code. Below this will either be returned directly or used to compute a value which is then cached, depending on the value of cache_hash r,__key(self.), self.rfN)rr8r^rl) prefixindentrcmp_namerwclosing_bracesrP hash_func method_lines type_hashs rappend_hash_computation_linesz1_make_hash..append_hash_computation_liness )+8I;a00   HAxxqvvhd+"#((h##xzxrBB##F}QVVHA-F$FG H FVOn<=rzif self.z is None:zobject.__setattr__(self, '', self. = z return self.zreturn rjrc)rDrr2rlr1rnrc)rrwrr tabrhash_defrrOrrPrrrs ` @@@@@rrgrgsO  E C/V>4CH->,?y"IIJ  ),->,?sCS1W    a# . ))*#.a  CL1B0C"DDE%i5 YY| $F  FOU CCrc.t||dd|_|S)z% Add a hash method to *cls*. Frf)rgrcrrws r _add_hashrsc55ICL Jrc d}|S)z Create __ne__ method. cF|j|}|turtS| S)zj Check equality and either forward a NotImplemented or return the result negated. )rxNotImplemented)rotherresults rryz_make_ne..__ne__#s( U# ^ #! !zrr)rys rr{r{s  Mrcr|Dcgc]}|js|}}t|d}gd}i}|r|jddg}|D]}|jrdd|jd}|j||<|jd|d|jd |jd|d |jd s|jd |jd |jd |jd |g|dz }n|jddj |}t d|||Scc}w)z6 Create __eq__ method for *cls* with *attrs*. r7)zdef __eq__(self, other):z- if other.__class__ is not self.__class__:z return NotImplementedz return (z ) == (rrrrrz(other.rrz other.z )z return Truerjrx)r7rrlr8r^rnrc) rrwrrrrPothersrrOs rrzrz1s= &1Q &E &/T:O E E  _% :Axxqvvhd+#$((h xzxrBC  '!&&DE }QVVHA67 qvvha89 : #6#7## &' YYu F &/5 AAC 's D4D4cDcgc]}|js|c}fdfd}fd}fd}fd}||||fScc}w)z9 Create ordering methods for *cls* with *attrs*. c<tdfdDDS)z& Save us some typing. c3:K|]\}}|r||n|ywr'r)rrrs rrz6_make_order..attrs_to_tuple..cs' sCJ5 ( sc3bK|]&}t|j|jf(ywr')rr^r:)rrobjs rrz6_make_order..attrs_to_tuple..es*89aff%q{{3s,/)rD)rrws`rattrs_to_tuplez#_make_order..attrs_to_tuple_s) =B   rcb|j|jur||kStSz1 Automatically created by attrs.  __class__rrrrs rrz_make_order..__lt__j0 ??dnn ,!$'.*?? ?rcb|j|jur||kStSrrrs rrz_make_order..__le__s0 ??dnn ,!$'>%+@@ @rcb|j|jur||kDStSrrrs rrz_make_order..__gt__|rrcb|j|jur||k\StSrrrs rrz_make_order..__ge__rr)r9)rrwrrrrrrs ` @rrrYsK )1Q )E   666 ))c *s??cb| |j}t|||_t|_|S)z5 Add equality methods to *cls* with *attrs*. )rrzrxr{ryrs r_add_eqrs0 }###u%CJCJ Jrct|d}td|D}|Dcic]\}}}|tk7s|dz|}}}}t|d<t|d<t |d<g} |D]B\}}} | rd|znd|zd z} |tk(r|d | d n |d |d | d } | j | Ddj| } |d}n|dz}ddddddddddddd|d| ddd g}td!d"j|||#Scc}}}w)$Nr0c3K|]I}|jdur9|j|jdurtn |j|jfKyw)FTN)r0r^r3rs rrz_make_repr..sC" 66  !&&D.$affqvv>"sAA_reprrr rrzgetattr(self, "z ", NOTHING)z={z!r}z_repr(z)}rz1{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))rrj)rP) rrDr0rr rrlrnrc)rwrMrrattr_names_with_reprsr^rrrPattribute_fragmentsrsaccessorfragment repr_fragmentcls_name_fragmentrs rrLrLs~/Vrrr)r generic_baserIrws rfieldsrs&$C(LJsD$9.n C*D 1E }  #L*;TBE ',# 89"3'' Lrct|ts d}t|t|dd}||d}t ||Dcic]}|j |c}Scc}w)aX 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 attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs* class. :rtype: dict .. versionadded:: 18.1.0 rrNr)rBr+r>rrr^)rrIrwrs r fields_dictr se c4 .n C*D 1E }89"3''$ %!AFFAI %% %sAc tjduryt|jD]/}|j}||||t ||j 1y)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_run_validatorsrrr/rr^)instrr;s rrr%sR%' DNN #. KK = dAwtQVV, -.rcd|jvS)Nr&)rrs r _is_slot_clsr6s #,, &&rc*||vxrt||S)z> Check if the attribute name comes from a slot class. )r)a_namers r _is_slot_attrr:s ] " J|M&4I'JJrc | duxr| tju} |r| r d} t| |xs|}g}i}|D]}|js|jt ur"|j ||||j<|j|dur d} t| d}b| se|jtjusd}t|d}t||||||||| || | \}}}|jtjvr6|jtj|jj|jt |d|rt j"|d<t%| rdnd|||}||_|S)Nz$Frozen classes can't use on_setattr.Tr3)r attr_dictrrur)rrr?r3r.rrlr^r;r_attrs_to_init_scriptrsysmodulesr)rrrrcr)rrwpre_initpre_init_has_args post_initrrr rr cls_on_setattrrkhas_cls_on_setattrrIneeds_cached_setattrfiltered_attrsr rrrOrP annotationsr3s rrmrmAs d"J~W]]'J$4o%/NI (vv!))w. a  !&& << #~< o%#' ALL $E#' ( 0V(4';';#$ &J  D 'D Krcd|d|dS)zJ Use the cached object.setattr to set *attr_name* to *value_var*. _setattr('rrrrt value_varhas_on_setattrs r_setattrrs {#i[ 22rc*d|dt|fzd|dS)zk Use the cached object.setattr to set *attr_name* to *value_var*, but run its converter first. rrrrg)_init_converter_patrs r_setattr_with_converterrs yl* rc0|r t||dSd|d|S)zo Unless *attr_name* has an on_setattr hook, use normal assignment. Otherwise relegate to _setattr. Trr)r)rtrrs r_assignrs)  5$// 9+S ((rcH|r t||dSd|dt|fzd|dS)z Unless *attr_name* has an on_setattr hook, use normal assignment after conversion. Otherwise relegate to _setattr_with_converter. Trrrr)rrrs r_assign_with_converterr!s7 &y)TBB yl* rc ^ g} |r| jd| r| jd|dur-|dur t} t}n(| jdfd} fd}n t} t}g}g}g}i}ddi}|D]}|j r|j||j }|jduxs |jtjuxr| }|j}t|jt}|r|jjrd nd }|jd ur|rt |j fz}|j"D| j|||d |d z|t$|j fz}|j"||<n | j| ||d |d z||jj&||<n|j"B| j||d|d|t$|j fz}|j"||<n| j| |d|d|n|jt(ur|s|d|d}|j*r|j|n|j||j"<| j|||||j"|t$|j fz<n| j| |||n|rI|d}|j*r|j|n|j|| jd|dt |j fz}|j"t| jd||||z| jd| jd|||d z|zd z|z|j"|t$|j fz<nR| jd| |||z| jd| jd| ||d z|zd z|z|jj&||<n|j*r|j|n|j||j";| j|||||j"|t$|j fz<n| j| ||||jdusU|j,|j"|j,||<~|j"t/|j"j1}|s|||<|rxt2|d<| jd|D]Y}d|j z}d|j z}| jd|d|d|j d |j ||<|||<[|r| jd|r&|r|rd}nd}nd}| j|t4d fz|r-d!j7d"|D} | jd#| d d$j7|}|}!|rO||rd$nd d%d$j7|z }d$j7|D"cgc] }"|"d&|" c}"}#|!|!rd$nd z }!|!|#z }!|r |rd'|!z| d(<d)| rd*nd+d|d,| rd-j7| nd.d/||fScc}"w)0z 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__``. zself.__attrs_pre_init__()z$_setattr = _cached_setattr_get(self)Tz_inst_dict = self.__dict__cFt|r t|||Sd|d|S)N _inst_dict[''] = )rrrtrrrs r fmt_setterz)_attrs_to_init_script..fmt_setters/ M:#Iy.II%i[i[AArcb|s t|r t|||Sd|dt|fzd|dS)Nr$r%rr)rrrr&s rfmt_setter_with_converterz8_attrs_to_init_script..fmt_setter_with_convertersG"]9m%L2!9n&M '9,6rreturnNrFrrz attr_dict['z '].defaultz =attr_dict['z=NOTHINGzif z is not NOTHING:rfzelse:rz#if _config._run_validators is True:__attr_validator___attr_z(self, z, self.zself.__attrs_post_init__()z_setattr('%s', %s)z_inst_dict['%s'] = %sz self.%s = %sNonerc3TK|] }|jsd|j"yw)rN)r3r^rs rrz(_attrs_to_init_script.. s!BQ166%x(Bs((zBaseException.__init__(self, rz*, =zself.__attrs_pre_init__(%s)rzdef rurz): z passrj)rlrrrr!r/r^r;rrr<rBr.rA takes_selfr3_init_factory_patr4rrHrr6r+r get_first_param_typerr1rn)$rwrrr rrr rr rrrkrr'r)args kw_only_argsattrs_to_validatenames_for_globalsrrrtrarg_name has_factory maybe_selfinit_factory_name conv_nameargtval_nameinit_hash_cachevals pre_init_argskw_argpre_init_kw_only_argss$ ` rr r s, E 01  3  ~ D=!J(? % LL5 6 B   $:! DLT"K M. ;;  $ $Q 'FF T1 LL - D2D  77 G4 *qyy/C/CV 66U?$5 $A!;;*LL1%-!Jvv!akk&9() H%((5JJL,-K)[M.^'.)$ :;" -A*QVV3H!AFF*I LL4z 7166(!L M*+++ h '+, i (  - 12 "6#:,O _(96'BBCxxB%BB 4TF!<= 99T?DM Db IIl #  !% 6B CF ' C!  !Dr  .. %0=@a ",  ; $)HMM% v 5     DsZ*r^r*c$|jdS)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)lstriprs rrr s ;;s rc`eZdZdZdZ d dZdZed dZdZ dZ d Z d Z y) ra *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 `. 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 ` 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/r0r7r8r9r:r2r3r5r+r4r6rr;r<Nct||xs| |xs|d\} }}}tj|}|d||d||d||d||d| |d||d||d ||d ||d ||d | |d | rtjt | nt |d| |d| |d||d||d|y)NTr^r.r/r0r7r8r9r:r2r3r4r5r+r6rr;r<)r=rrtypesMappingProxyTyper_empty_metadata_singleton)rr^r.r/r0r1r2r3rr5r+r4r6r7r8r9r:r;r< bound_setattrs rrzAttribute.__init__* s*(B 2y1E4( $FE9 %,,T2  fd#i)k9-fd#dBh'gu%k9-fd#fd#k9- &&tH~6.   fd#i)k9-lJ/gu%rctr'rrs rrzAttribute.__setattr__a s !##rc | |j}n|j d}t|tjDcic]}|dvr |t ||}}|d||j |j |ddd|Scc}w)Nz8Type annotation and type argument cannot both be present)r^r/r.r+rF)r^r/r.r+r1rr)r+r?rr&r _validator_default)rr^rr+rIr: inst_dicts rrzAttribute.from_counting_attrd s <77D WW LCS/ !((   wr1~     mmKK      sA8c ntj|}|j|j|S)z Copy *self* and apply *changes*. This works similarly to `attrs.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)rchangesnews rrzAttribute.evolve s(iio gmmo& rc@tfdjDS)( Play nice with pickle. c3jK|]*}|dk7r t|ntj,yw)r5N)rrr5rr^rs rrz)Attribute.__getstate__.. s5 $(:#5GD$ 4 ;N N s03rDr&rs`rrzAttribute.__getstate__ s#    rcN|jt|j|yrYN)rUr]r&)rr^s rrzAttribute.__setstate__ s s4>>512rc tj|}|D]A\}}|dk7r ||||||rtjt |nt Cy)Nr5)rrrJrKrrL)rname_values_pairsrMr^rs rrUzAttribute._setattrs s\$,,T2 , KD%z!dE***4;72  r) NNNFNNNNNNr') rrr r!r&rrr5rrrrrUrrrrr sb)VI<  '5&n$  <$ 3 rrr5) r^r.r/r0r1r7r9r2r3rr<)rwrc|eZdZdZdZgeddDeddddddddddddddd Zd Zd Z d Z d Z y)rGa 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. )rrQr0r7r8r9r:r2r3r5rPr4r+r6r;r<c#jK|]+}t|t|tdddddddddddd-yw)NTFr^r<r.r/r0r1r2r3r6r7r8r9r:rr;)rrr)rr^s rrz_CountingAttr. sV $# -d3   s13) rrQr0r7r9r2r3r;r<r5NTFrcrc2txjdz c_tj|_||_||_||_||_| |_| |_| |_ ||_ ||_ ||_ ||_ | |_| |_||_||_yr)rG cls_counterrrQrPr4r0r7r8r9r:r2r3r5r+r6r;r<)rr.r/r0r1r2r3r4r5r+r6r7r8r9r:r;r<s rrz_CountingAttr.__init__ s& !!Q&!$00  #"   "      $ rcf|j ||_|St|j||_|S)z Decorator that adds *meth* to the list of validators. Returns *meth* unchanged. .. versionadded:: 17.1.0 )rPrFrrs rr/z_CountingAttr.validator? s5 ?? ""DO #4??D9DO rcb|jtur tt|d|_|S)z Decorator that allows to set the default for an attribute. Returns *meth* unchanged. :raises DefaultAlreadySetError: If default has been set before. .. versionadded:: 17.1.0 T)r2)rQrr rArgs rr.z_CountingAttr.defaultM s, == '(* *6  r) rrr r!r&rDrrrerr/r.rrrrGrG sI$0  $ %  0>  ?0ObK#J rrGc(eZdZdZdZddZdZdZy)rAa Stores a factory callable. If passed as the default value to `attrs.field`, 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* rHr2c ||_||_yr'rj)rrHr2s rrzFactory.__init__s s $rc@tfdjDS)rYc36K|]}t|ywr'rYr[s rrz'Factory.__getstate__..{ sDTWT4(Dsr\rs`rrzFactory.__getstate__w sDT^^DDDrcZt|j|D]\}}t|||yr^)r]r&r")rr^r^rs rrzFactory.__setstate__} s.t~~u5 'KD% D$ & 'rN)F)rrr r!r&rrrrrrrArAb s *I%E 'rrA) r^r.r/r0r1r7r9r2r3rc $ t|tr|}n. s $rrr__main__r1r7r9Trr)rBrrCrDrJr>popr)rJ new_classrrr r?r  _getframe f_globalsrrrr)r^rwbases class_bodyattributes_argumentscls_dictrrIr r user_inittype_r1rqs @r make_classr} s:% ED%= ))./AAvxK//8n||0$7H 2D9I Z.I D J%- !"&/ "#$Z OOD%-G HE   ^Z 8 ==+5599     " "5$ /C "   &  )  T"W% :6 9 9$8 9% @@U02  sF*5FF)rr2c$eZdZdZeZdZy) _AndValidatorz2 Compose many validators to a single one. c:|jD] }||||yr') _validators)rrrrr;s r__call__z_AndValidator.__call__ s#!! !A dD%  !rN)rrr r!rJrrrrrrr s(K!rrcg}|D]0}|jt|tr |jn|g2tt |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 )rrBrrrD) validatorsrBr/s rrFrF sO D  )]3  ! !   t %%rc fd}s!tjd}||d|_|Stdj }|r||jd<tdj }|r||jd<|S)aY 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. :param callables converters: Arbitrary number of converters. .. versionadded:: 20.1.0 c&D] }||} |Sr'r)rr4 converterss rpipe_converterzpipe..pipe_converter s"# !IC.C ! rA)rr*rrrVr*)typingTypeVarrr r4get_return_type)rrrr?rts` rrErE s  NN3 12a)@&  !A / D D F 45N * *5 1"*R. 1 A A C 79N * *8 4 r)Nr+)T)NNNNNNNFFTFFFFFNNFFNNNTNr')NN)arrTr"r*rr2r[r rJroperatorrr+rrrrr r r exceptionsr r rrobjectrrrr3rr1rKrLrrErrrEnumrrintr%rJrTrcrurvrrrrrrrrrrrr=rrwrrrrgrr{rzrrrLrrrrrrmrrrr!r r}rrr&_ar^r2rGrA_fr}rrF)r^rs00rrs  (' !! +')2E2226 H %goow7G7GHtyy(    ( ("        Tn :":%  0"  #>%8jGZ5p   MM`8((X.26         1Yx  /DDN&%BP5*p 6r'T&2."'KL^3 ) _D ##EEl##     j %d+ "  )2&6Q+ 5q6 =AFFqvv'<1 =   PPf -01  ' '`!!         GIgR8C2 NyTJAbT ! ! !&*$s (7 =zs**#J>!K6KK K 'K #K