3737 DEFAULT_CHUNK_SIZE ,
3838 EMPTY ,
3939 NEWLN ,
40- _clear_entity_type_registry ,
4140 _grid_in_property ,
4241 _grid_out_property ,
42+ _clear_entity_type_registry ,
4343)
4444from pymongo import ASCENDING , DESCENDING , WriteConcern , _csot
45+ from pymongo .synchronous .client_session import ClientSession
46+ from pymongo .synchronous .collection import Collection
47+ from pymongo .synchronous .cursor import Cursor
48+ from pymongo .synchronous .database import Database
49+ from pymongo .synchronous .helpers import next
4550from pymongo .common import validate_string
4651from pymongo .errors import (
4752 BulkWriteError ,
5358)
5459from pymongo .helpers_shared import _check_write_command_response
5560from pymongo .read_preferences import ReadPreference , _ServerMode
56- from pymongo .synchronous .client_session import ClientSession
57- from pymongo .synchronous .collection import Collection
58- from pymongo .synchronous .cursor import Cursor
59- from pymongo .synchronous .database import Database
60- from pymongo .synchronous .helpers import next
6161
6262_IS_SYNC = True
6363
@@ -302,7 +302,9 @@ def list(self, session: Optional[ClientSession] = None) -> list[str]:
302302 # With an index, distinct includes documents with no filename
303303 # as None.
304304 return [
305- name for name in self ._files .distinct ("filename" , session = session ) if name is not None
305+ name
306+ for name in self ._files .distinct ("filename" , session = session )
307+ if name is not None
306308 ]
307309
308310 def find_one (
@@ -679,7 +681,9 @@ def upload_from_stream(
679681 .. versionchanged:: 3.6
680682 Added ``session`` parameter.
681683 """
682- with self .open_upload_stream (filename , chunk_size_bytes , metadata , session = session ) as gin :
684+ with self .open_upload_stream (
685+ filename , chunk_size_bytes , metadata , session = session
686+ ) as gin :
683687 gin .write (source )
684688
685689 return cast (ObjectId , gin ._id )
@@ -831,7 +835,9 @@ def delete(self, file_id: Any, session: Optional[ClientSession] = None) -> None:
831835 raise NoFile ("no file could be deleted because none matched %s" % file_id )
832836
833837 @_csot .apply
834- def delete_by_name (self , filename : str , session : Optional [ClientSession ] = None ) -> None :
838+ def delete_by_name (
839+ self , filename : str , session : Optional [ClientSession ] = None
840+ ) -> None :
835841 """Given a filename, delete this stored file's files collection document(s)
836842 and associated chunks from a GridFS bucket.
837843
@@ -1002,7 +1008,9 @@ def download_to_stream_by_name(
10021008 .. versionchanged:: 3.6
10031009 Added ``session`` parameter.
10041010 """
1005- with self .open_download_stream_by_name (filename , revision , session = session ) as gout :
1011+ with self .open_download_stream_by_name (
1012+ filename , revision , session = session
1013+ ) as gout :
10061014 while True :
10071015 chunk = gout .readchunk ()
10081016 if not len (chunk ):
@@ -1163,7 +1171,9 @@ def __init__(
11631171 object .__setattr__ (self , "_buffered_docs" , [])
11641172 object .__setattr__ (self , "_buffered_docs_size" , 0 )
11651173
1166- def _create_index (self , collection : Collection [Any ], index_key : Any , unique : bool ) -> None :
1174+ def _create_index (
1175+ self , collection : Collection [Any ], index_key : Any , unique : bool
1176+ ) -> None :
11671177 doc = collection .find_one (projection = {"_id" : 1 }, session = self ._session )
11681178 if doc is None :
11691179 try :
@@ -1174,7 +1184,9 @@ def _create_index(self, collection: Collection[Any], index_key: Any, unique: boo
11741184 except OperationFailure :
11751185 index_keys = []
11761186 if index_key not in index_keys :
1177- collection .create_index (index_key .items (), unique = unique , session = self ._session )
1187+ collection .create_index (
1188+ index_key .items (), unique = unique , session = self ._session
1189+ )
11781190
11791191 def _ensure_indexes (self ) -> None :
11801192 if not object .__getattribute__ (self , "_ensured_index" ):
@@ -1908,7 +1920,9 @@ def close(self) -> None:
19081920
19091921
19101922class GridOutIterator :
1911- def __init__ (self , grid_out : GridOut , chunks : Collection [Any ], session : ClientSession ):
1923+ def __init__ (
1924+ self , grid_out : GridOut , chunks : Collection [Any ], session : ClientSession
1925+ ):
19121926 self ._chunk_iter = GridOutChunkIterator (grid_out , chunks , session , 0 )
19131927
19141928 def __iter__ (self ) -> GridOutIterator :
0 commit comments