@@ -77,7 +77,9 @@ method for added type safety:
77
77
class Restaurant(TypedDict):
78
78
name: str
79
79
80
- sample_restaurants.restaurants.insert_one(Movie(name="Mongo's Burgers")
80
+ sample_restaurants.restaurants.insert_one(Restaurant(name="Mongo's Burgers")
81
+
82
+ .. include:: /includes/type-hints/tip-type-checkers.rst
81
83
82
84
Insert Multiple Documents
83
85
-------------------------
@@ -121,6 +123,8 @@ instances of the ``Restaurant`` class. This adds type safety to the insert opera
121
123
122
124
sample_restaurants.restaurants.insert_many(document_list)
123
125
126
+ .. include:: /includes/type-hints/tip-type-checkers.rst
127
+
124
128
Modify Insert Behavior
125
129
----------------------
126
130
@@ -205,7 +209,7 @@ calling the ``insert_many()`` method instead.
205
209
TypedDict Missing _id Key
206
210
~~~~~~~~~~~~~~~~~~~~~~~~~
207
211
208
- As discussed above, if you don't specify the ``_id`` field, {+driver-short+} automatically
212
+ If you don't specify the ``_id`` field, {+driver-short+} automatically
209
213
inserts it into the document.
210
214
You can retrieve the value of the ``_id`` field at runtime, but if you use MyPy or another
211
215
tool to perform static type-checking, it won't find the ``_id`` field in your class and
@@ -313,8 +317,10 @@ The following code example shows how to implement this solution:
313
317
314
318
.. important:: NotRequired Requires Python 3.11+
315
319
316
- The ``NotRequired`` class is available only in Python 3.11 and later.
317
- To use ``NotRequired`` in earlier versions of Python, install the ``typing_extensions``
320
+ The `NotRequired <https://docs.python.org/3/library/typing.html#typing.NotRequired>`__
321
+ class is available only in Python 3.11 and later.
322
+ To use ``NotRequired`` in earlier versions of Python, install the
323
+ `typing_extensions <https://pypi.org/project/typing-extensions/>`__
318
324
package instead.
319
325
320
326
Additional Information
0 commit comments