zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
U
¸ý°dá•ã@s¼UdZddlmZddlmZddlmZddlmZddlmZddlmZddlm    Z    dd    lm
Z
dd
lm Z dd lm Z dd lm Z dd lZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddlmZ"ddlm#Z#dd lm$Z$dd!l%m&Z&dd"l%m'Z'e r<dd#lm(Z(dd$lm)Z)dd%lm*Z*dd&l+m,Z,dd'l+m-Z-dd(lm.Z.dd)l/m0Z0dd*l1m2Z2dd+l3m4Z4dd,lm5Z5dd-l6m7Z7dd.l8m9Z9dd/l:m;Z;dd0l<m=Z>dd1l<m?Z?e rLd2e@d3<nd ZAe sZd Z>Gd4d5„d5e'ƒZBGd6d7„d7e'eƒZCe#jDGd8d9„d9ejEeeƒƒZFGd:d;„d;ƒZGGd<d=„d=ƒZHd S)>zŸDefines instrumentation of instances.
 
This module is usually not directly visible to user applications, but
defines a large part of the ORM's interactivity.
 
é)Ú annotations)ÚAny)ÚCallable)ÚDict)ÚGeneric)ÚIterable)ÚOptional)ÚSet)ÚTuple)Ú TYPE_CHECKING)ÚUnionNé)Úbase)Úexc)Ú
interfaces)Ú_O)Úis_collection_impl)Ú ATTR_WAS_SET)ÚINIT_OK)ÚLoaderCallableStatus)Ú    NEVER_SET)ÚNO_VALUE)ÚPASSIVE_NO_INITIALIZE)ÚPASSIVE_NO_RESULT)Ú PASSIVE_OFF)ÚSQL_OK)Ú PathRegistryé)Ú
inspection)Úutil)ÚLiteral)ÚProtocol)Ú_IdentityKeyType)Ú _InstanceDict)Ú_LoaderCallable)Ú AttributeImpl)ÚHistory)Ú PassiveFlag)Ú_AdaptedCollectionProtocol)Ú IdentityMap)Ú ClassManager)Ú    ORMOption)ÚMapper)ÚSession)ÚRow)Ú async_session)Ú AsyncSessionz)weakref.WeakValueDictionary[int, Session]Ú    _sessionsc@seZdZddœdd„ZdS)Ú_InstanceDictProtoúOptional[IdentityMap]©ÚreturncCsdS©N©©Úselfr7r7úKd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/orm/state.pyÚ__call__Qsz_InstanceDictProto.__call__N)Ú__name__Ú
__module__Ú __qualname__r;r7r7r7r:r2Psr2c@s$eZdZdZdddddœdd„Zd    S)
Ú_InstallLoaderCallableProtoaused at result loading time to install a _LoaderCallable callable
    upon a specific InstanceState, which will be used to populate an
    attribute when that attribute is accessed.
 
    Concrete examples are per-instance deferred column loaders and
    relationship lazy loaders.
 
    úInstanceState[_O]r#úRow[Any]ÚNone©ÚstateÚdict_Úrowr5cCsdSr6r7)r9rDrErFr7r7r:r;_sz$_InstallLoaderCallableProto.__call__N)r<r=r>Ú__doc__r;r7r7r7r:r?Us    r?c@speZdZUdZdZded<dZded<dZded    <dZded
<d Z    d ed <e
j Z ded<dZ ded<dZded<ded<ded<dZded<dZded<dZded<dZded<dZded<dZded<dZd ed!<dZd"ed#<d$ed%<esôd&d'„Zd(ed)<d*ed+<esejZd,dd-œd.d/„Zejd0d1œd2d3„ƒZedd1œd4d5„ƒZ edd1œd6d7„ƒZ!edd1œd8d9„ƒZ"edd1œd:d;„ƒZ#edd1œd<d=„ƒZ$edd1œd>d?„ƒZ%ej&e 'd@¡dd1œdAdB„ƒƒZ(dCdDdEœdFdG„Z)edHd1œdIdJ„ƒZ*edKd1œdLdM„ƒZ+edNd1œdOdP„ƒZ,edQd1œdRdS„ƒZ-edd1œdTdU„ƒZ.ejdVd1œdWdX„ƒZ/ejdYd1œdZd[„ƒZ0ejd\d1œd]d^„ƒZ1ejd_d1œd`da„ƒZ2edd1œdbdc„ƒZ3e4d»dddeddDdfœdgdh„ƒZ5d¼dHdDdiœdjdk„Z6dDd1œdldm„Z7ddDdnœdodp„Z8edqd1œdrds„ƒZ9dtdtdDduœdvdw„Z:dCdxdydzœd{d|„Z;dCd}dEœd~d„Z<dCd€dEœdd‚„Z=dd1œdƒd„„Z>ddDd…œd†d‡„Z?dqdCdDdˆœd‰dŠ„Z@d‹dDdŒœddŽ„ZAe4dddtdd‘œd’d“„ƒZBdqd”dDd•œd–d—„ZCd½dqd˜ddDd™œdšd›„ZDdœdxddžœdŸd „ZEed(d1œd¡d¢„ƒZFd˜d(d£œd¤d¥„ZGed(d1œd¦d§„ƒZHed(d1œd¨d©„ƒZIed(d1œdªd«„ƒZJd¾dqd¬dtdddDd­œd®d¯„ZKdqd˜dDd°œd±d²„ZLd¿dqd³dDd´œdµd¶„ZMe4dÀd·d³dDd¸œd¹dº„ƒZNdS)ÁÚ InstanceStatea tracks state information at the instance level.
 
    The :class:`.InstanceState` is a key object used by the
    SQLAlchemy ORM in order to track the state of an object;
    it is created the moment an object is instantiated, typically
    as a result of :term:`instrumentation` which SQLAlchemy applies
    to the ``__init__()`` method of the class.
 
    :class:`.InstanceState` is also a semi-public object,
    available for runtime inspection as to the state of a
    mapped instance, including information such as its current
    status within a particular :class:`.Session` and details
    about data on individual attributes.  The public API
    in order to acquire a :class:`.InstanceState` object
    is to use the :func:`_sa.inspect` system::
 
        >>> from sqlalchemy import inspect
        >>> insp = inspect(some_mapped_object)
        >>> insp.attrs.nickname.history
        History(added=['new nickname'], unchanged=(), deleted=['nickname'])
 
    .. seealso::
 
        :ref:`orm_mapper_inspection_instancestate`
 
    )Ú__dict__Ú __weakref__Úclass_ÚmanagerÚobjÚcommitted_stateÚexpired_attributeszClassManager[_O]rLNz Optional[int]Ú
session_idzOptional[_IdentityKeyType[_O]]ÚkeyÚrunidr7zTuple[ORMOption, ...]Ú load_optionsrÚ    load_pathÚ insert_orderzOptional[object]Ú _strong_objzweakref.ref[_O]rMzDict[str, Any]rNFÚboolÚmodifiedÚexpiredÚ_deletedÚ _load_pendingÚ_orphaned_outside_of_sessionTÚ is_instanceÚobjectÚidentity_tokenzOptional[Dict[str, Any]]Ú_last_known_valuesr2Ú_instance_dictcCsdS)z+default 'weak reference' for _instance_dictNr7r8r7r7r:ra¨szInstanceState._instance_dictzSet[str]rOz:Dict[str, Callable[[InstanceState[_O], PassiveFlag], Any]]Ú    callablesr)rMrLcCs0|j|_||_t ||j¡|_i|_tƒ|_    dSr6)
Ú    __class__rKrLÚweakrefÚrefÚ_cleanuprMrNÚsetrO)r9rMrLr7r7r:Ú__init__Ãs
zInstanceState.__init__z'util.ReadOnlyProperties[AttributeState]r4cst ‡fdd„ˆjDƒ¡S)aaReturn a namespace representing each attribute on
        the mapped object, including its current value
        and history.
 
        The returned object is an instance of :class:`.AttributeState`.
        This object allows inspection of the current data
        within an attribute as well as attribute history
        since the last flush.
 
        csi|]}|tˆ|ƒ“qSr7)ÚAttributeState)Ú.0rQr8r7r:Ú
<dictcomp>×sz'InstanceState.attrs.<locals>.<dictcomp>)rZReadOnlyPropertiesrLr8r7r8r:ÚattrsÊs ÿzInstanceState.attrscCs|jdko|j S)z}Return ``True`` if the object is :term:`transient`.
 
        .. seealso::
 
            :ref:`session_object_states`
 
        N©rQÚ    _attachedr8r7r7r:Ú    transientÚs    zInstanceState.transientcCs|jdko|jS)z|Return ``True`` if the object is :term:`pending`.
 
 
        .. seealso::
 
            :ref:`session_object_states`
 
        Nrmr8r7r7r:Úpendingås
zInstanceState.pendingcCs|jdk    o|jo|jS)aðReturn ``True`` if the object is :term:`deleted`.
 
        An object that is in the deleted state is guaranteed to
        not be within the :attr:`.Session.identity_map` of its parent
        :class:`.Session`; however if the session's transaction is rolled
        back, the object will be restored to the persistent state and
        the identity map.
 
        .. note::
 
            The :attr:`.InstanceState.deleted` attribute refers to a specific
            state of the object that occurs between the "persistent" and
            "detached" states; once the object is :term:`detached`, the
            :attr:`.InstanceState.deleted` attribute **no longer returns
            True**; in order to detect that a state was deleted, regardless
            of whether or not the object is associated with a
            :class:`.Session`, use the :attr:`.InstanceState.was_deleted`
            accessor.
 
        .. versionadded: 1.1
 
        .. seealso::
 
            :ref:`session_object_states`
 
        N©rQrnrZr8r7r7r:ÚdeletedñszInstanceState.deletedcCs|jS)aNReturn True if this object is or was previously in the
        "deleted" state and has not been reverted to persistent.
 
        This flag returns True once the object was deleted in flush.
        When the object is expunged from the session either explicitly
        or via transaction commit and enters the "detached" state,
        this flag will continue to report True.
 
        .. seealso::
 
            :attr:`.InstanceState.deleted` - refers to the "deleted" state
 
            :func:`.orm.util.was_deleted` - standalone function
 
            :ref:`session_object_states`
 
        )rZr8r7r7r:Ú was_deletedszInstanceState.was_deletedcCs|jdk    o|jo|j S)aReturn ``True`` if the object is :term:`persistent`.
 
        An object that is in the persistent state is guaranteed to
        be within the :attr:`.Session.identity_map` of its parent
        :class:`.Session`.
 
        .. seealso::
 
            :ref:`session_object_states`
 
        Nrqr8r7r7r:Ú
persistent$s zInstanceState.persistentcCs|jdk    o|j S)z|Return ``True`` if the object is :term:`detached`.
 
        .. seealso::
 
            :ref:`session_object_states`
 
        Nrmr8r7r7r:Údetached3s    zInstanceState.detachedzsqlalchemy.orm.sessioncCs|jdk    o|jtjjjkSr6)rPrZ    preloadedZ orm_sessionr1r8r7r7r:rn>s
þzInstanceState._attachedÚstrrB)rQr5cCs,|j}|dkri|_}||kr(t||<dS)z|Track the last known value of a particular key after expiration
        operations.
 
        .. versionadded:: 1.3
 
        N)r`r)r9rQÚlkvr7r7r:Ú_track_last_known_valueFs
 
z%InstanceState._track_last_known_valuezOptional[Session]cCs,|jr(z t|jWStk
r&YnXdS)aLReturn the owning :class:`.Session` for this instance,
        or ``None`` if none available.
 
        Note that the result here can in some cases be *different*
        from that of ``obj in session``; an object that's been deleted
        will report as not ``in session``, however if the transaction is
        still in progress, this attribute will still refer to that session.
        Only when the transaction is completed does the object become
        fully detached under normal circumstances.
 
        .. seealso::
 
            :attr:`_orm.InstanceState.async_session`
 
        N)rPr1ÚKeyErrorr8r7r7r:ÚsessionTs  zInstanceState.sessionzOptional[AsyncSession]cCs*tdkr dS|j}|dk    r"t|ƒSdSdS)aGReturn the owning :class:`_asyncio.AsyncSession` for this instance,
        or ``None`` if none available.
 
        This attribute is only non-None when the :mod:`sqlalchemy.ext.asyncio`
        API is in use for this ORM object. The returned
        :class:`_asyncio.AsyncSession` object will be a proxy for the
        :class:`_orm.Session` object that would be returned from the
        :attr:`_orm.InstanceState.session` attribute for this
        :class:`_orm.InstanceState`.
 
        .. versionadded:: 1.4.18
 
        .. seealso::
 
            :ref:`asyncio_toplevel`
 
        N)Ú_async_providerrz)r9Úsessr7r7r:r/ls zInstanceState.async_sessionz Optional[_O]cCs| ¡S)z–Return the mapped object represented by this
        :class:`.InstanceState`.
 
        Returns None if the object has been garbage collected
 
        )rMr8r7r7r:r^ˆszInstanceState.objectzOptional[Tuple[Any, ...]]cCs|jdkrdS|jdSdS)aìReturn the mapped identity of the mapped object.
        This is the primary key identity as persisted by the ORM
        which can always be passed directly to
        :meth:`_query.Query.get`.
 
        Returns ``None`` if the object has no primary key identity.
 
        .. note::
            An object which is :term:`transient` or :term:`pending`
            does **not** have a mapped identity until it is flushed,
            even if its attributes include primary key values.
 
        Nr ©rQr8r7r7r:Úidentity’s
zInstanceState.identitycCs|jS)zõReturn the identity key for the mapped object.
 
        This is the key used to locate the object within
        the :attr:`.Session.identity_map` mapping.   It contains
        the identity as returned by :attr:`.identity` within it.
 
 
        r}r8r7r7r:Ú identity_key¦s
zInstanceState.identity_keyz4Dict[int, Union[Literal[False], InstanceState[Any]]]cCsiSr6r7r8r7r7r:Úparents²szInstanceState.parentszDict[str, PendingCollection]cCsiSr6r7r8r7r7r:Ú_pending_mutations¶sz InstanceState._pending_mutationsz%Dict[str, _AdaptedCollectionProtocol]cCsiSr6r7r8r7r7r:Ú_empty_collectionsºsz InstanceState._empty_collectionsz
Mapper[_O]cCs|jjS)z<Return the :class:`_orm.Mapper` used for this mapped object.)rLÚmapperr8r7r7r:rƒ¾szInstanceState.mappercCs
t|jƒS)z³Return ``True`` if this object has an identity key.
 
        This should always have the same value as the
        expression ``state.persistent`` or ``state.detached``.
 
        )rWrQr8r7r7r:Ú has_identityÃszInstanceState.has_identityzIterable[InstanceState[_O]]r-)ÚstatesrzÚ to_transientr5c CsÒ|jjp
d}|jjpd}|jjp"d}|jjp.d}|D]˜}|j}    |jdk}
|
oR|     } d|_|rh|jrh|`| r˜|r„|dk    r–|||ƒqÆ|dk    rÆ|||ƒn.|    r°|dk    r°|||ƒn|
rÆ|dk    rÆ|||ƒd|_q4dSr6)    ÚdispatchÚpersistent_to_detachedÚdeleted_to_detachedÚpending_to_transientÚpersistent_to_transientrZrQrPrV) r9r…rzr†rˆr‰rŠr‹rDrrrprtr7r7r:Ú_detach_statesÍs0
ÿ  
ÿ
 
 
zInstanceState._detach_states)rzr5cCs$|rt |g|¡n d|_|_dSr6)rHrŒrPrV)r9rzr7r7r:Ú_detachószInstanceState._detachcCs | ¡dSr6)rr8r7r7r:Ú_disposeùszInstanceState._dispose)rer5cCs:tdkr dS| ¡}|dk    r*| |¡|`d|_|_dS)zäWeakref callback cleanup.
 
        This callable cleans out the state when it is being garbage
        collected.
 
        this _cleanup **assumes** that there are no strong refs to us!
        Will not work otherwise!
 
        N)ÚdictraZ _fast_discardrPrV)r9reÚ instance_dictr7r7r:rfýs
zInstanceState._cleanupr#cCs"| ¡}|dk    rt |¡SiSdS)aReturn the instance dict used by the object.
 
        Under normal circumstances, this is always synonymous
        with the ``__dict__`` attribute of the mapped object,
        unless an alternative instrumentation system has been
        configured.
 
        In the case that the actual object has been garbage
        collected, this accessor returns a blank dictionary.
 
        N)rMrr)r9Úor7r7r:rs 
zInstanceState.dictr)ÚmixedÚkwargsr5c Os„|d|d|dd…}}}|j}|j |||¡z|j|dd…|ŽWn0t ¡|j |||¡W5QRXYnXdS)Nrr r)rLr‡ÚinitZ original_initrZ safe_reraiseZ init_failure)r’r“r9ÚinstanceÚargsrLr7r7r:Ú_initialize_instance-s 
z"InstanceState._initialize_instancer'r&)rQÚpassiver5cCs|j|j ||j|¡Sr6)rLÚimplÚ get_historyr)r9rQr˜r7r7r:rš9szInstanceState.get_historyr%cCs |j|jSr6)rLr™©r9rQr7r7r:Úget_impl<szInstanceState.get_implÚPendingCollectioncCs ||jkrtƒ|j|<|j|Sr6)rrr›r7r7r:Ú_get_pending_mutation?s
 z#InstanceState._get_pending_mutationcsZˆ ¡ˆjˆjˆjdœ}| ‡fdd„dDƒ¡ˆjrDˆj ¡|d<ˆj ˆ|¡|d<|S)N)r•rKrNrOc3s&|]}|ˆjkr|ˆj|fVqdSr6)rI©rjÚkr8r7r:Ú    <genexpr>Ks
óz-InstanceState.__getstate__.<locals>.<genexpr>)
rrXrYrbrQr€rSrKrOÚinforTrL)    rMrKrNrOÚupdaterTÚ    serializerLÚ
_serialize)r9Ú
state_dictr7r8r:Ú __getstate__DsüþzInstanceState.__getstate__)r¦r5cs2ˆd}|dk    r*t ||j¡|_|j|_ndd„|_ˆd|_ˆ di¡|_ˆ di¡|_ˆ di¡|_    ˆ dd    ¡|_
ˆ d
d    ¡|_ d ˆkrœ|j   ˆd ¡d ˆkrºˆd |_ˆd |_nd ˆkrΈd |_ntƒ|_|j  ‡fdd„dDƒ¡|jr|jd|_dˆkrt ˆd¡|_ˆd||ˆƒdS)Nr•cSsdSr6r7r7r7r7r:Ú<lambda>hóz,InstanceState.__setstate__.<locals>.<lambda>rKrNrr€rXFrYr¢rbrOcs g|]}|ˆkr|ˆ|f‘qSr7r7rŸ©r¦r7r:Ú
<listcomp>}sþz.InstanceState.__setstate__.<locals>.<listcomp>)rQrSrrTrL)rdrerfrMrcrKÚgetrNrr€rXrYr¢r£rbrOrgrIrQr_rZ deserializerT)r9r¦Úinstr7rªr:Ú __setstate__bs:
 
 
 
 
þÿ 
zInstanceState.__setstate__)rErQr5cCsV| |d¡}|j|j}|dk    r2t|ƒr2| |¡|j |¡|jrR|j |d¡dS)zHRemove the given attribute and any
        callables associated with it.N)ÚpoprLr™rÚ_invalidate_collectionrOÚdiscardrb)r9rErQÚoldZ manager_implr7r7r:Ú_reset‹s  
 zInstanceState._resetúInstanceState[Any])Úfrom_r5cCsd|jkrt|jƒ|_dS©Nrb)rIrrb)r9rµr7r7r:Ú_copy_callables—s
zInstanceState._copy_callablesr$z_InstallLoaderCallableProto[_O])rLÚfnrQr5csR|ˆj}t|ƒr4|‰dddddœ‡‡‡fdd„ }ndddddœ‡‡fdd„ }|S)    Nr@r#rArBrCcs<d|jkri|_| ˆd¡}|dk    r.ˆ |¡ˆ|jˆ<dSr¶)rIrbr¯r°)rDrErFr²©Z
fixed_implr¸rQr7r:Ú _set_callable£s 
 
zGInstanceState._instance_level_callable_processor.<locals>._set_callablecsd|jkri|_ˆ|jˆ<dSr¶)rIrb)rDrErF)r¸rQr7r:rº¯s
)r™r)ÚclsrLr¸rQr™rºr7r¹r:Ú"_instance_level_callable_processor›s 
 z0InstanceState._instance_level_callable_processorzSet[InstanceState[Any]])rEÚ modified_setr5csd|_|jr&| |¡|j ¡d|_d|_d|jkr>|jd=d|jkrP|jd=|j dd„|j    j
Dƒ¡|j rŒ|j  |j ¡D] }|j |=q~|j    j   ˆ¡D]}ˆ |¡}d|j_qš|jrÔ|j ‡fdd„|jDƒ¡|j    j  ˆ¡D]
}ˆ|=qâ|j    j |d¡dS)    NTFrr€cSsg|]
}|j‘qSr7r})rjr™r7r7r:r«Êsz)InstanceState._expire.<locals>.<listcomp>csi|]}|ˆkr|ˆ|“qSr7r7rŸ©rEr7r:rkâsz)InstanceState._expire.<locals>.<dictcomp>)rYrXr±rNÚclearrVrIrOr£rLZ _loader_implsrbÚ intersectionZ_collection_impl_keysr¯Z _sa_adapterZ invalidatedr`Z _all_key_setr‡Úexpire)r9rEr½r Ú
collectionrQr7r¾r:Ú_expire¸s4
 
 
 
ÿ 
 
 
ÿzInstanceState._expirez Iterable[str])rEÚattribute_namesÚ    no_loaderr5c
Csà|j dd¡}|j}|D]²}|j|j}|jr`|rB|js||krBq|j |¡|r`||kr`||=|     |t
¡}t |ƒr†|t
k    r†|  |¡|j }    |    dk    r¬||    kr¬|t
k    r¬||    |<|j     |d¡|r|     |d¡q|jj ||¡dS)Nr)rIr¬rbrLr™Úaccepts_scalar_loaderZ    callable_rOÚaddr¯rrr°r`rNr‡rÁ)
r9rErÄrÅrprbrQr™r²rwr7r7r:Ú_expire_attributesês(    
z InstanceState._expire_attributesr@r)rDr˜r5csP|t@s tSˆj ˆj¡}| ‡fdd„|Dƒ¡}ˆj ˆ||¡ˆj ¡t    S)z¡__call__ allows the InstanceState to act as a deferred
        callable for loading expired attributes, which is also
        serializable (picklable).
 
        c3s |]}ˆj|jjs|VqdSr6)rLr™Zload_on_unexpire©rjÚattrr8r7r:r¡sþz.InstanceState._load_expired.<locals>.<genexpr>)
rrrOrÀÚ
unmodifiedÚ
differencerLZexpired_attribute_loaderr¿r)r9rDr˜Ztoloadr7r8r:Ú _load_expired s    þ
zInstanceState._load_expiredcCst|jƒ |j¡S)z8Return the set of keys which have no uncommitted changes)rgrLrÌrNr8r7r7r:rË(szInstanceState.unmodified)Úkeysr5cCst|ƒ |j¡ |j¡S)z*Return self.unmodified.intersection(keys).)rgrÀrLrÌrN)r9rÎr7r7r:Úunmodified_intersection.s ÿþÿz%InstanceState.unmodified_intersectioncCst|jƒ |j¡ |j¡S©z²Return the set of keys which do not have a loaded value.
 
        This includes expired attributes and any other attribute that
        was never populated or modified.
 
        )rgrLrÌrNrr8r7r7r:Úunloaded7s     
ÿþÿzInstanceState.unloadedcCs|jSrÐ)rÑr8r7r7r:Úunloaded_expirableEsz InstanceState.unloaded_expirablecsˆj ‡fdd„ˆjDƒ¡S)Nc3s |]}ˆj|jjr|VqdSr6)rLr™rÆrÉr8r7r:r¡Qsþz5InstanceState._unloaded_non_object.<locals>.<genexpr>)rÑrÀrLr8r7r8r:Ú_unloaded_non_objectOsþz"InstanceState._unloaded_non_objectzOptional[AttributeImpl])rErÊÚpreviousrÂÚ is_userlandr5c Cs‚|r²|jsdS|r,|j|kr,t d|j¡‚|j|jks<|r|r„trPt|ƒsPt‚|tkrl|j|krl||j}|dt    tfkr„| 
|¡}||j|j<|j }|dk    r²|j|kr²t    ||j<|j rÂ|j dksÊ|js~d|_| ¡}|rôt|jƒ}|j |¡nd}| ¡}    |j rN|    |_ |sNzt|j }
Wntk
r8YnX|
jdkrN|
 ¡|    dkr~|r~t d|j|jt |¡f¡‚dS)NzHCan't flag attribute '%s' modified; it's not present in the object stateTFzaCan't emit change event for attribute '%s' - parent object of type %s has been garbage collected.)Zsend_modified_eventsrQÚsa_excZInvalidRequestErrorrNr rÚAssertionErrorrrÚcopyr`rPrVrXrarWÚ    _modifiedrÇrMr1ryZ _transactionZ _autobegin_tÚorm_excZObjectDereferencedErrorrLrZstate_class_str) r9rErÊrÔrÂrÕrwrZ has_modifiedr­rzr7r7r:Ú_modified_eventWsZÿÿ 
 
 
 
 
 ýÿzInstanceState._modified_event)rErÎr5cCsb|D]}|j |d¡qd|_|j t|ƒ |¡¡|jr^t|jƒ |¡ |¡D] }|j|=qPdS)a8Commit attributes.
 
        This is used by a partial-attribute load operation to mark committed
        those attributes which were refreshed from the database.
 
        Attributes marked as "expired" can potentially remain "expired" after
        this step if a value was not populated in state.dict.
 
        NF)rNr¯rYrOÚdifference_updatergrÀrb)r9rErÎrQr7r7r:Ú_commitŸs
 ÿÿzInstanceState._commitr3)rErr5cCs| ||fg|¡dS)aScommit all attributes unconditionally.
 
        This is used after a flush() or a full load/refresh
        to remove all pending state from the instance.
 
         - all attributes are marked as "committed"
         - the "strong dirty reference" is removed
         - the "modified" flag is set to False
         - any "expired" markers for scalar attributes loaded are removed.
         - lazy load callables for objects / collections *stay*
 
        Attributes marked as "expired" can potentially remain
        "expired" after this step if a value was not populated in state.dict.
 
        N)Ú_commit_all_states)r9rErr7r7r:Ú _commit_all¼szInstanceState._commit_allz2Iterable[Tuple[InstanceState[Any], _InstanceDict]])Úiter_rr5cCsd|D]Z\}}|j}|j ¡d|kr*|d=|j |¡|rL|jrL|j |¡d|_|_d|_    qdS)z.Mass / highly inlined version of commit_all().rFN)
rIrNr¿rOrÜrXrÙr±rYrV)r9ràrrDrEr¦r7r7r:rÞÐs 
 
  z InstanceState._commit_all_states)F)N)F)FF)N)N)Or<r=r>rGÚ    __slots__Ú__annotations__rPrQrRrSrÚrootrTrUrVrXrYrZr[r\r]r_r`r rarÚ
EMPTY_DICTrbrhZmemoized_propertyrlÚpropertyrorprrrsrtruZnon_memoized_propertyZpreload_modulernrxrzr/r^r~rr€rr‚rƒr„Ú classmethodrŒrrŽrfrr—ršrœržr§r®r³r·r¼rÃrÈrÍrËrÏrÑrÒrÓrÛrÝrßrÞr7r7r7r:rHesÔ
 
 
 
         ü% ) 6ü!          úHÿýrHc@szeZdZUdZdZded<ded<dddœdd„Zed    d
œd d „ƒZed    d
œd d„ƒZ    edd
œdd„ƒZ
dd
œdd„Z dS)riaŠProvide an inspection interface corresponding
    to a particular attribute on a particular mapped object.
 
    The :class:`.AttributeState` object is accessed
    via the :attr:`.InstanceState.attrs` collection
    of a particular :class:`.InstanceState`::
 
        from sqlalchemy import inspect
 
        insp = inspect(some_mapped_object)
        attr_state = insp.attrs.some_attribute
 
    ©rDrQr´rDrvrQcCs||_||_dSr6rç)r9rDrQr7r7r:rhýszAttributeState.__init__rr4cCs|jj |jt¡S)zÇThe current value of this attribute as loaded from the database.
 
        If the value has not been loaded, or is otherwise not present
        in the object's dictionary, returns NO_VALUE.
 
        )rDrr¬rQrr8r7r7r:Ú loaded_valueszAttributeState.loaded_valuecCs |jj|j |j ¡|jj¡S)zàReturn the value of this attribute.
 
        This operation is equivalent to accessing the object's
        attribute directly or via ``getattr()``, and will fire
        off any pending loader callables if needed.
 
        )rDrLrQÚ__get__rMrKr8r7r7r:Úvalue s    ÿzAttributeState.valuer&cCs|j |jt¡S)aiReturn the current **pre-flush** change history for
        this attribute, via the :class:`.History` interface.
 
        This method will **not** emit loader callables if the value of the
        attribute is unloaded.
 
        .. note::
 
            The attribute history system tracks changes on a **per flush
            basis**. Each time the :class:`.Session` is flushed, the history
            of each attribute is reset to empty.   The :class:`.Session` by
            default autoflushes each time a :class:`_query.Query` is invoked.
            For
            options on how to control this, see :ref:`session_flushing`.
 
 
        .. seealso::
 
            :meth:`.AttributeState.load_history` - retrieve history
            using loader callables if the value is not locally present.
 
            :func:`.attributes.get_history` - underlying function
 
        )rDršrQrr8r7r7r:ÚhistoryszAttributeState.historycCs|j |jttA¡S)aReturn the current **pre-flush** change history for
        this attribute, via the :class:`.History` interface.
 
        This method **will** emit loader callables if the value of the
        attribute is unloaded.
 
        .. note::
 
            The attribute history system tracks changes on a **per flush
            basis**. Each time the :class:`.Session` is flushed, the history
            of each attribute is reset to empty.   The :class:`.Session` by
            default autoflushes each time a :class:`_query.Query` is invoked.
            For
            options on how to control this, see :ref:`session_flushing`.
 
        .. seealso::
 
            :attr:`.AttributeState.history`
 
            :func:`.attributes.get_history` - underlying function
 
        )rDršrQrrr8r7r7r:Ú load_history4szAttributeState.load_historyN) r<r=r>rGrárârhrårèrêrërìr7r7r7r:riés
     ric@sTeZdZUdZdZded<ded<ddœd    d
„Zd dd œd d„Zd dd œdd„ZdS)raA writable placeholder for an unloaded collection.
 
    Stores items appended to and removed from a collection that has not yet
    been loaded. When the collection is loaded, the changes stored in
    PendingCollection are applied to it to produce the final result.
 
    )Ú deleted_itemsÚ added_itemszutil.IdentitySetrízutil.OrderedIdentitySetrîrBr4cCst ¡|_t ¡|_dSr6)rZ IdentitySetríZOrderedIdentitySetrîr8r7r7r:rh\s
zPendingCollection.__init__r)rêr5cCs(||jkr|j |¡n |j |¡dSr6)ríÚremoverîrÇ©r9rêr7r7r:Úappend`s
zPendingCollection.appendcCs(||jkr|j |¡n |j |¡dSr6)rîrïrírÇrðr7r7r:rïfs
zPendingCollection.removeN)    r<r=r>rGrárârhrñrïr7r7r7r:rNs
r)IrGÚ
__future__rÚtypingrrrrrrr    r
r r rdÚrrrÚrÚ_typingrrrrrrrrrrrZ path_registryrrÖrrZ util.typingr r!r"r#r$Ú
attributesr%r&r'Ú collectionsr(r~r)Zinstrumentationr*r+rƒr,rzr-Zenginer.Zext.asyncio.sessionr/r{r0râr1r2r?Z_self_inspectsZInspectionAttrInforHrirr7r7r7r:Ú<module>s„                                              

e