@@ -183,30 +183,30 @@ def handle_response(self, response: "GetResponse") -> None:
183
183
184
184
class LazySessionOperations :
185
185
def __init__ (self , delegate : DocumentSession ):
186
- self ._delegate = delegate
186
+ self ._session = delegate
187
187
188
188
def include (self , path : str ) -> LazyMultiLoaderWithInclude :
189
- return LazyMultiLoaderWithInclude (self ._delegate ).include (path )
189
+ return LazyMultiLoaderWithInclude (self ._session ).include (path )
190
190
191
191
def load (
192
- self , ids : Union [List [str ], str ], object_type : Type [_T ], on_eval : Callable = None
192
+ self , ids : Union [List [str ], str ], object_type : Optional [ Type [_T ]] = None , on_eval : Callable = None
193
193
) -> Optional [Lazy [Union [Dict [str , object ], object ]]]:
194
194
if not ids :
195
195
return None
196
196
197
197
if isinstance (ids , str ):
198
198
key = ids
199
- if self ._delegate .advanced .is_loaded (key ):
200
- return Lazy (lambda : self ._delegate .load (key , object_type ))
199
+ if self ._session .advanced .is_loaded (key ):
200
+ return Lazy (lambda : self ._session .load (key , object_type ))
201
201
202
202
lazy_load_operation = LazyLoadOperation (
203
- object_type , self ._delegate , LoadOperation (self ._delegate ).by_key (key )
203
+ object_type , self ._session , LoadOperation (self ._session ).by_key (key )
204
204
).by_key (key )
205
205
206
- return self ._delegate .add_lazy_operation (object_type , lazy_load_operation , on_eval )
206
+ return self ._session .add_lazy_operation (object_type , lazy_load_operation , on_eval )
207
207
208
208
elif isinstance (ids , list ):
209
- return self ._delegate .lazy_load_internal (object_type , ids , [], on_eval )
209
+ return self ._session .lazy_load_internal (object_type , ids , [], on_eval )
210
210
211
211
raise TypeError (f"Expected a 'str' or 'list' of 'str', the document ids. Got '{ type (ids ).__name__ } '." )
212
212
@@ -221,24 +221,24 @@ def load_starting_with(
221
221
start_after : str = None ,
222
222
) -> Lazy [Dict [str , _T ]]:
223
223
operation = LazyStartsWithOperation (
224
- object_type , id_prefix , matches , exclude , start , page_size , self ._delegate , start_after
224
+ object_type , id_prefix , matches , exclude , start , page_size , self ._session , start_after
225
225
)
226
226
227
- return self ._delegate .add_lazy_operation (dict , operation , None )
227
+ return self ._session .add_lazy_operation (dict , operation , None )
228
228
229
229
def conditional_load (
230
- self , key : str , change_vector : str , object_type : Type [_T ] = None
230
+ self , key : str , change_vector : str , object_type : Optional [ Type [_T ] ] = None
231
231
) -> Lazy [ConditionalLoadResult [_T ]]:
232
232
if not key or key .isspace ():
233
233
raise ValueError ("key cannot be None or whitespace" )
234
234
235
- if self ._delegate .is_loaded (key ):
235
+ if self ._session .is_loaded (key ):
236
236
237
237
def __lazy_factory ():
238
- entity = self ._delegate .load (key , object_type )
238
+ entity = self ._session .load (key , object_type )
239
239
if entity is None :
240
240
return ConditionalLoadResult .create (None , None )
241
- cv = self ._delegate .advanced .get_change_vector_for (entity )
241
+ cv = self ._session .advanced .get_change_vector_for (entity )
242
242
return ConditionalLoadResult .create (entity , cv )
243
243
244
244
return Lazy (__lazy_factory )
@@ -249,8 +249,8 @@ def __lazy_factory():
249
249
f"conditional load when change_vector is None or empty"
250
250
)
251
251
252
- lazy_load_operation = LazyConditionalLoadOperation (object_type , key , change_vector , self ._delegate )
253
- return self ._delegate .add_lazy_operation (ConditionalLoadResult , lazy_load_operation , None )
252
+ lazy_load_operation = LazyConditionalLoadOperation (object_type , key , change_vector , self ._session )
253
+ return self ._session .add_lazy_operation (ConditionalLoadResult , lazy_load_operation , None )
254
254
255
255
256
256
class LazyLoadOperation (LazyOperation ):
0 commit comments