Skip to content

Commit 301d38a

Browse files
committed
tech review
1 parent c420d12 commit 301d38a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

source/connect/mongoclient.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,13 @@ constructor accepts. All parameters are optional.
132132

133133
* - ``document_class``
134134
- The default class that the client uses to decode BSON documents returned by queries.
135-
This parameter supports the following types:
135+
This parameter accepts the following types:
136136

137-
- ``bson.raw_bson.RawBSONDocument``.
137+
- ``bson.raw_bson.RawBSONDocument``. To learn more about the ``RawBSONDocument`` class,
138+
see :ref:`pymongo-bson-raw`.
139+
138140
- A subclass of the ``collections.abc.Mapping`` type, such as ``bson.son.SON``.
139-
If you specify ``bson.son.SON`` as the document class, you must also specify types
141+
If you specify ``bson.son.SON`` as the document class, you may also specify types
140142
for the key and value, as shown in the following example:
141143

142144
.. code-block:: python
@@ -265,6 +267,17 @@ The following example shows how to include this data type in your type annotatio
265267
from typing import Any, Dict
266268
client: MongoClient[Dict[str, Any]] = MongoClient()
267269

270+
If all the documents that you are working with correspond to a single custom type, you
271+
can specify the custom type as a type hint for your ``MongoClient`` object. This
272+
provides more accurate type information than the generic ``Dict[str, Any]`` type.
273+
274+
The following example shows how to specify the ``Movie`` type as a type hint for a
275+
``MongoClient`` object:
276+
277+
.. code-block:: python
278+
279+
client: MongoClient[Movie] = MongoClient()
280+
268281
Troubleshooting
269282
---------------
270283

0 commit comments

Comments
 (0)