zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
U
L±dZAã@sŒddlZddlmZmZddlmZmZmZddlm    Z    dde
ddfdd    „Z d
d „Z dde dfd d „Zdd„Zdd„Zdd„Zddd„ZdS)éNé)Ú PY_3_9_PLUSÚget_generic_base)ÚNOTHINGÚ _obj_setattrÚfields)ÚAttrsAttributeNotFoundErrorTFc     st|jƒ}ˆƒ}|D]ü}t||jƒ}    ˆdk    r8ˆ||    ƒs8qˆdk    rLˆ|||    ƒ}    |dkrt|    jƒr|t|    dˆˆˆˆd||j<nˆt|    ttt    t
fƒrĈdkrœ|    jnt}
|
‡‡‡‡fdd„|    Dƒƒ||j<n@t|    t ƒrúˆ‰ˆ‡‡‡‡fdd„|      ¡Dƒƒ||j<n
|    ||j<q|    ||j<q|S)a]
    Return the *attrs* attribute values of *inst* as a dict.
 
    Optionally recurse into other *attrs*-decorated classes.
 
    :param inst: Instance of an *attrs*-decorated class.
    :param bool recurse: Recurse into classes that are also
        *attrs*-decorated.
    :param callable filter: 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.
    :param callable dict_factory: A callable to produce dictionaries from.  For
        example, to produce ordered dictionaries instead of normal Python
        dictionaries, pass in ``collections.OrderedDict``.
    :param bool retain_collection_types: Do not convert to ``list`` when
        encountering an attribute whose type is ``tuple`` or ``set``.  Only
        meaningful if ``recurse`` is ``True``.
    :param Optional[callable] value_serializer: 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.
 
    :rtype: return type of *dict_factory*
 
    :raise 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.
    NT©ÚrecurseÚfilterÚ dict_factoryÚretain_collection_typesÚvalue_serializerc
s g|]}t|dˆˆˆˆd‘qS©F©Úis_keyr r r r©Ú_asdict_anything©Ú.0Úi©r r r r©úBd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\attr/_funcs.pyÚ
<listcomp>Ls    øúzasdict.<locals>.<listcomp>c
3s:|]2\}}t|dˆˆˆˆdt|dˆˆˆˆdfVqdS©TrFNr©rÚkkÚvv©Údfr r rrrÚ    <genexpr>Zs$ïúú÷zasdict.<locals>.<genexpr>) rÚ    __class__ÚgetattrÚnameÚhasÚasdictÚ
isinstanceÚtupleÚlistÚsetÚ    frozensetÚdictÚitems) Úinstr
r r r rÚattrsÚrvÚaÚvÚcfr©r r r r rrr& sB*
 
 
ú    ÷ÿ
í  r&csÂt|jddƒdk    r(t|dˆˆˆˆd}n–t|ttttfƒrvˆdkrJ|j}n|rTt}nt}|‡‡‡‡fdd„|Dƒƒ}nHt|tƒr¦ˆ‰ˆ‡‡‡‡fdd„|     ¡Dƒƒ}n|}ˆdk    r¾ˆdd|ƒ}|S)    zK
    ``asdict`` only works on attrs instances, this works on anything.
    Ú__attrs_attrs__NTr    c
s g|]}t|dˆˆˆˆd‘qSrrrrrrr”s    øúz$_asdict_anything.<locals>.<listcomp>c
3s:|]2\}}t|dˆˆˆˆdt|dˆˆˆˆdfVqdSrrrrrrr!¢s$ïúú÷z#_asdict_anything.<locals>.<genexpr>)
r#r"r&r'r(r)r*r+r,r-)Úvalrr r r rr0r3rr4rrvs: ú    ÷ÿ
í
 rc
st|jƒ}g}|‰|D]ì}t||jƒ}ˆdk    r:ˆ||ƒs:q|dkrøt|jƒrf| t|dˆˆˆd¡nt|tt    t
t fƒr¬ˆdkr†|jnt    }    | |    ‡‡‡fdd„|Dƒƒ¡nJt|t ƒrìˆdkrÄ|jnt }
| |
‡‡fdd„|  ¡Dƒƒ¡n
| |¡q| |¡qˆt    kr|Sˆ|ƒS)a)
    Return the *attrs* attribute values of *inst* as a tuple.
 
    Optionally recurse into other *attrs*-decorated classes.
 
    :param inst: Instance of an *attrs*-decorated class.
    :param bool recurse: Recurse into classes that are also
        *attrs*-decorated.
    :param callable filter: 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.
    :param callable tuple_factory: A callable to produce tuples from.  For
        example, to produce lists instead of tuples.
    :param bool retain_collection_types: Do not convert to ``list``
        or ``dict`` when encountering an attribute which type is
        ``tuple``, ``dict`` or ``set``.  Only meaningful if ``recurse`` is
        ``True``.
 
    :rtype: return type of *tuple_factory*
 
    :raise attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs*
        class.
 
    ..  versionadded:: 16.2.0
    NT©r
r Ú tuple_factoryr c    s,g|]$}t|jƒr$t|dˆˆˆdn|‘qS)Tr7©r%r"Úastuple)rÚj©r Úretainr8rrrös
þùûzastuple.<locals>.<listcomp>c3sJ|]B\}}t|jƒr"t|ˆˆdn|t|jƒr<t|ˆˆdn|fVqdS))r8r Nr9r)r=r8rrr!s öûýûýòzastuple.<locals>.<genexpr>)rr"r#r$r%Úappendr:r'r(r)r*r+r,r-) r.r
r r8r r/r0r1r2r3r rr<rr:¿sJ!
 
ûÿ    
öÿÿ
ïÿ  r:cCsNt|ddƒ}|dk    rdSt|ƒ}|dk    rJt|ddƒ}|dk    rB||_|dk    SdS)z­
    Check whether *cls* is a class with *attrs* attributes.
 
    :param type cls: Class to introspect.
    :raise TypeError: If *cls* is not a class.
 
    :rtype: bool
    r5NTF)r#rr5)Úclsr/Z generic_baseZ generic_attrsrrrr%#s      r%cKs`t |¡}t|jƒ}| ¡D]>\}}t||tƒ}|tkrNt|›d|j›dƒ‚t|||ƒq|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
 
    :param inst: Instance of a class with *attrs* attributes.
    :param changes: Keyword changes in the new copy.
 
    :return: A copy of inst with *changes* incorporated.
 
    :raise attrs.exceptions.AttrsAttributeNotFoundError: If *attr_name*
        couldn't be found on *cls*.
    :raise 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`.
    z is not an attrs attribute on Ú.)Úcopyrr"r-r#rrr)r.ÚchangesÚnewr/Úkr2r1rrrÚassoc;s
 
 ÿrEc    OsÎ|r<z
|\}Wq‚tk
r8tdt|ƒ›dƒd‚Yq‚XnFz| d¡}Wntk
rhtdƒd‚YnXddl}|jdtdd    |j}t    |ƒ}|D].}|j
s q”|j }|j }||kr”t ||ƒ||<q”|f|ŽS)
aõ
    Create a new instance, based on the first positional argument with
    *changes* applied.
 
    :param inst: Instance of a class with *attrs* attributes.
    :param changes: Keyword changes in the new copy.
 
    :return: A copy of inst with *changes* incorporated.
 
    :raise TypeError: If *attr_name* couldn't be found in the class
        ``__init__``.
    :raise attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs*
        class.
 
    .. versionadded:: 17.1.0
    .. deprecated:: 23.1.0
       It is now deprecated to pass the instance using the keyword argument
       *inst*. It will raise a warning until at least April 2024, after which
       it will become an error. Always pass the instance as a positional
       argument.
    z*evolve() takes 1 positional argument, but z  were givenNr.z7evolve() missing 1 required positional argument: 'inst'rzgPassing the instance per keyword argument is deprecated and will stop working in, or after, April 2024.é)Ú
stacklevel)Ú
ValueErrorÚ    TypeErrorÚlenÚpopÚKeyErrorÚwarningsÚwarnÚDeprecationWarningr"rÚinitr$Úaliasr#)    ÚargsrBr.rMr?r/r1Ú    attr_nameZ    init_namerrrÚevolvebsB
ÿý
ÿþürTc    Cs|t|ddƒ|krxddl}||dœ}tr.||d<|j|f|Ž}|dkrLt|ƒn|D] }|j|krPt|d||jƒqP||_|S)aA
    Resolve any strings and forward annotations in type annotations.
 
    This is only required if you need concrete types in `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, e.g. 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.
 
    :param type cls: Class to resolve.
    :param Optional[dict] globalns: Dictionary containing global variables.
    :param Optional[dict] localns: Dictionary containing local variables.
    :param Optional[list] attribs: 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.
    :param bool include_extras: 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.
 
    :raise TypeError: If *cls* is not a class.
    :raise attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs*
        class and you didn't pass any attribs.
    :raise 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)ÚglobalnsÚlocalnsÚinclude_extrasÚtype)r#ÚtypingrÚget_type_hintsrr$rrU)    r?rVrWZattribsrXrZÚkwargsÚhintsÚfieldrrrÚ resolve_types s+
 
r_)NNNT)rAÚ_compatrrÚ_makerrrÚ
exceptionsrr,r&rr(r:r%rErTr_rrrrÚ<module>s. ú
kKû
d'?ÿ