L i_@ ddlZddlmZddlmZmZmZddlmZe e de e e eeee de eeh Zddeddfd Zd Zddedfd Zd Zd Z ddZy)N)get_generic_base) _OBJ_SETATTRNOTHINGfields)AttrsAttributeNotFoundError.TFc Pt|j}|}|D]G}t||j}  || s& ||| } |durt | } | t vr| ||j<Zt | rt| d|||j<t| ttttfrAdur| nt} | D cgc]} t| d|} } | | ||j<t| tr3|fd| j!D||j<(| ||j<9| ||j<J|Scc} w#t$r't| ts| | ||j<YwxYw)a Return the *attrs* attribute values of *inst* as a dict. Optionally recurse into other *attrs*-decorated classes. Args: inst: Instance of an *attrs*-decorated class. recurse (bool): Recurse into classes that are also *attrs*-decorated. filter (~typing.Callable): A callable whose return code determines whether an attribute or element is included (`True`) or dropped (`False`). Is called with the `attrs.Attribute` as the first argument and the value as the second argument. dict_factory (~typing.Callable): A callable to produce dictionaries from. For example, to produce ordered dictionaries instead of normal Python dictionaries, pass in ``collections.OrderedDict``. retain_collection_types (bool): Do not convert to `list` when encountering an attribute whose type is `tuple` or `set`. Only meaningful if *recurse* is `True`. value_serializer (typing.Callable | None): A hook that is called for every attribute or dict key/value. It receives the current instance, field and value and must return the (updated) value. The hook is run *after* the optional *filter* has been applied. Returns: Return type of *dict_factory*. Raises: attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs* class. .. versionadded:: 16.0.0 *dict_factory* .. versionadded:: 16.1.0 *retain_collection_types* .. versionadded:: 20.3.0 *value_serializer* .. versionadded:: 21.3.0 If a dict has a collection for a key, it is serialized as a tuple. Trecursefilter dict_factoryretain_collection_typesvalue_serializerFis_keyr r rrc 3hK|])\}}t|dt|df+ywTrFN_asdict_anything.0kkvvdfr rrs Q/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/attr/_funcs.py zasdict..~sW &B#)#'#))+4K-= )#(#))+4K-=  /2)r __class__getattrnametype _ATOMIC_TYPEShasasdict issubclasstuplelistset frozensetr TypeErrordictitems)instr r r rrattrsrvav value_typecfir,rs ` `` @rr$r$sh 4>> "E B D D!&& !  fQl   ' q!,A d?aJ]*166 Z# !!-,C%5 166 Jc9(EF#:d#BZ %$%%10G)9   ,!#EBqvvJJ-! &#$'')' 166 ,166 BqvvJIDJ I] !,%b%0"$UBqvvJ ,sE02E55,F%$F%c  t|}|tvr|} dd|}|St|ddt|d|}|St |t t ttfrGdur |j}n|rt }nt }||D cgc]} t| d|c} }|St |tr&|  fd|jD}|S|} dd|}|Scc} w)zK ``asdict`` only works on attrs instances, this works on anything. N__attrs_attrs__Tr Frc 3hK|])\}}t|dt|df+ywrrrs rrz#_asdict_anything..sW &B#!!!#,C%5 ! !!#,C%5   r) r!r"rr$r%r&r'r(r)rrr+r,) valrr r rrval_typer/r3r4rs ` `` @rrrsBCyH=   '!$b1Bx Iw ,d 3 ?  %$;-  r Ic HudC; < "d *B BB  ! !!-,C%5    R I9 Hd #   &))+'  4 I   '!$b1B IQ sC5c t|j}g}||D]n}t||j}| |||s&t |} |dur(| t vr|j |Pt| r |j t|d|{t| ttttfrcdur |jnt} |D cgc])} t| jrt| d|n| +} } |j | | t| tr=dur| nt} |j | fd|j!DK|j |^|j |qtur|S|Scc} w#t$r)t| ts|j | | YwxYw)az Return the *attrs* attribute values of *inst* as a tuple. Optionally recurse into other *attrs*-decorated classes. Args: inst: Instance of an *attrs*-decorated class. recurse (bool): Recurse into classes that are also *attrs*-decorated. filter (~typing.Callable): A callable whose return code determines whether an attribute or element is included (`True`) or dropped (`False`). Is called with the `attrs.Attribute` as the first argument and the value as the second argument. tuple_factory (~typing.Callable): A callable to produce tuples from. For example, to produce lists instead of tuples. retain_collection_types (bool): Do not convert to `list` or `dict` when encountering an attribute which type is `tuple`, `dict` or `set`. Only meaningful if *recurse* is `True`. Returns: Return type of *tuple_factory* Raises: attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs* class. .. versionadded:: 16.2.0 T)r r tuple_factoryrc3K|]Q\}}t|jrt|n|t|jrt|n|fSyw))r;rN)r#rastuple)rrrretainr;s rrzastuple..Bsk*#B$'r||#4 !($&2?s ` @rr=r=sT 4>> "E B $F H D!&& !  fQl !W d?]* ! Z  $%&306 Jc9(EF$*dNQ[[ q{{+ $(#)*74:   *IIbi(J-#)T>Zt *'(ggi+4 ! IIaLQHT$&2=M",==m  !*%b%0IIb%j) *s.F"F''.GGcrt|dd}|yt|}|t|dd}|||_|duSy)z Check whether *cls* is a class with *attrs* attributes. Args: cls (type): Class to introspect. Raises: TypeError: If *cls* is not a class. Returns: bool: r6NTF)rrr6)clsr. generic_base generic_attrss rr#r#bsY C*D 1E $C(L .?F  $"/C D(( c tj|}t|j}|jD]H\}}t ||t }|t ur|d|jd}t |t|||J|S)a Copy *inst* and apply *changes*. This is different from `evolve` that applies the changes to the arguments that create the new instance. `evolve`'s behavior is preferable, but there are `edge cases`_ where it doesn't work. Therefore `assoc` is deprecated, but will not be removed. .. _`edge cases`: https://github.com/python-attrs/attrs/issues/251 Args: inst: Instance of a class with *attrs* attributes. changes: Keyword changes in the new copy. Returns: A copy of inst with *changes* incorporated. Raises: attrs.exceptions.AttrsAttributeNotFoundError: If *attr_name* couldn't be found on *cls*. attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs* class. .. deprecated:: 17.1.0 Use `attrs.evolve` instead if you can. This function will not be removed du to the slightly different approach compared to `attrs.evolve`, though. z is not an attrs attribute on .)copyrrr,rrrr)r-changesnewr.kr1r0msgs rassocrM~s@ ))D/C 4>> "E  1 E1g & <C5cmm_AFC-c2 2S!Q  JrEct|dd|k7raddl}|||d}|j|fi|}| t|n|D]+}|j|vst |d||j-||_|S)a Resolve any strings and forward annotations in type annotations. This is only required if you need concrete types in :class:`Attribute`'s *type* field. In other words, you don't need to resolve your types if you only use them for static type checking. With no arguments, names will be looked up in the module in which the class was created. If this is not what you want, for example, if the name only exists inside a method, you may pass *globalns* or *localns* to specify other dictionaries in which to look up these names. See the docs of `typing.get_type_hints` for more details. Args: cls (type): Class to resolve. globalns (dict | None): Dictionary containing global variables. localns (dict | None): Dictionary containing local variables. attribs (list | None): List of attribs for the given class. This is necessary when calling from inside a ``field_transformer`` since *cls* is not an *attrs* class yet. include_extras (bool): Resolve more accurately, if possible. Pass ``include_extras`` to ``typing.get_hints``, if supported by the typing module. On supported Python versions (3.9+), this resolves the types more accurately. Raises: TypeError: If *cls* is not a class. attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs* class and you didn't pass any attribs. NameError: If types cannot be resolved because of missing variables. Returns: *cls* so you can use this function also as a class decorator. Please note that you have to apply it **after** `attrs.define`. That means the decorator has to come in the line **before** `attrs.define`. .. versionadded:: 20.1.0 .. versionadded:: 21.1.0 *attribs* .. versionadded:: 23.1.0 *include_extras* __attrs_types_resolved__Nr)globalnslocalnsinclude_extrasr!)rtypingget_type_hintsrr rrO) rBrPrQattribsrRrSkwargshintsfields r resolve_typesrYsjs.5<!,  &%%c4V4$+OVC[ ?EzzU"UFE%**,=> ? (+$ JrE)NNNT)rH_compatr_makerrr exceptionsrr)r!boolintfloatstrcomplexbytesrangepropertyr"r+r$rr&r=r#rMrYrErrfs %003 T       S     &  ! {|K`  ! w>t8(XDHHrE