42
42
_grid_out_property ,
43
43
)
44
44
from pymongo import ASCENDING , DESCENDING , WriteConcern , _csot
45
+ from pymongo .common import validate_string
45
46
from pymongo .errors import (
46
47
BulkWriteError ,
47
48
ConfigurationError ,
50
51
InvalidOperation ,
51
52
OperationFailure ,
52
53
)
54
+ from pymongo .helpers_shared import _check_write_command_response
55
+ from pymongo .read_preferences import ReadPreference , _ServerMode
53
56
from pymongo .synchronous .client_session import ClientSession
54
57
from pymongo .synchronous .collection import Collection
55
- from pymongo .synchronous .common import validate_string
56
58
from pymongo .synchronous .cursor import Cursor
57
59
from pymongo .synchronous .database import Database
58
- from pymongo .synchronous .helpers import _check_write_command_response , next
59
- from pymongo .synchronous .read_preferences import ReadPreference , _ServerMode
60
+ from pymongo .synchronous .helpers import next
60
61
61
62
_IS_SYNC = True
62
63
@@ -234,7 +235,10 @@ def get_version(
234
235
raise NoFile ("no version %d for filename %r" % (version , filename )) from None
235
236
236
237
def get_last_version (
237
- self , filename : Optional [str ] = None , session : Optional [ClientSession ] = None , ** kwargs : Any
238
+ self ,
239
+ filename : Optional [str ] = None ,
240
+ session : Optional [ClientSession ] = None ,
241
+ ** kwargs : Any ,
238
242
) -> GridOut :
239
243
"""Get the most recent version of a file in GridFS by ``"filename"``
240
244
or metadata fields.
@@ -497,7 +501,7 @@ def __init__(
497
501
.. seealso:: The MongoDB documentation on `gridfs <https://dochub.mongodb.org/core/gridfs>`_.
498
502
"""
499
503
if not isinstance (db , Database ):
500
- raise TypeError ("database must be an instance of AsyncDatabase " )
504
+ raise TypeError ("database must be an instance of Database " )
501
505
502
506
db = _clear_entity_type_registry (db )
503
507
@@ -1028,7 +1032,7 @@ def __init__(
1028
1032
provided by :class:`~gridfs.GridFS`.
1029
1033
1030
1034
Raises :class:`TypeError` if `root_collection` is not an
1031
- instance of :class:`~pymongo.collection.AsyncCollection `.
1035
+ instance of :class:`~pymongo.collection.Collection `.
1032
1036
1033
1037
Any of the file level options specified in the `GridFS Spec
1034
1038
<http://dochub.mongodb.org/core/gridfsspec>`_ may be passed as
@@ -1069,10 +1073,10 @@ def __init__(
1069
1073
1070
1074
.. versionchanged:: 3.0
1071
1075
`root_collection` must use an acknowledged
1072
- :attr:`~pymongo.collection.AsyncCollection .write_concern`
1076
+ :attr:`~pymongo.collection.Collection .write_concern`
1073
1077
"""
1074
1078
if not isinstance (root_collection , Collection ):
1075
- raise TypeError ("root_collection must be an instance of AsyncCollection " )
1079
+ raise TypeError ("root_collection must be an instance of Collection " )
1076
1080
1077
1081
if not root_collection .write_concern .acknowledged :
1078
1082
raise ConfigurationError ("root_collection must use acknowledged write_concern" )
@@ -1401,7 +1405,7 @@ def __init__(
1401
1405
Either `file_id` or `file_document` must be specified,
1402
1406
`file_document` will be given priority if present. Raises
1403
1407
:class:`TypeError` if `root_collection` is not an instance of
1404
- :class:`~pymongo.collection.AsyncCollection `.
1408
+ :class:`~pymongo.collection.Collection `.
1405
1409
1406
1410
:param root_collection: root collection to read from
1407
1411
:param file_id: value of ``"_id"`` for the file to read
@@ -1424,7 +1428,7 @@ def __init__(
1424
1428
from the server. Metadata is fetched when first needed.
1425
1429
"""
1426
1430
if not isinstance (root_collection , Collection ):
1427
- raise TypeError ("root_collection must be an instance of AsyncCollection " )
1431
+ raise TypeError ("root_collection must be an instance of Collection " )
1428
1432
_disallow_transactions (session )
1429
1433
1430
1434
root_collection = _clear_entity_type_registry (root_collection )
@@ -1482,7 +1486,7 @@ def __getattr__(self, name: str) -> Any:
1482
1486
self .open () # type: ignore[unused-coroutine]
1483
1487
elif not self ._file :
1484
1488
raise InvalidOperation (
1485
- "You must call AsyncGridOut .open() before accessing the %s property" % name
1489
+ "You must call GridOut .open() before accessing the %s property" % name
1486
1490
)
1487
1491
if name in self ._file :
1488
1492
return self ._file [name ]
@@ -1677,13 +1681,13 @@ def writable(self) -> bool:
1677
1681
return False
1678
1682
1679
1683
def __enter__ (self ) -> GridOut :
1680
- """Makes it possible to use :class:`AsyncGridOut ` files
1684
+ """Makes it possible to use :class:`GridOut ` files
1681
1685
with the async context manager protocol.
1682
1686
"""
1683
1687
return self
1684
1688
1685
1689
def __exit__ (self , exc_type : Any , exc_val : Any , exc_tb : Any ) -> Any :
1686
- """Makes it possible to use :class:`AsyncGridOut ` files
1690
+ """Makes it possible to use :class:`GridOut ` files
1687
1691
with the async context manager protocol.
1688
1692
"""
1689
1693
self .close ()
0 commit comments