@@ -105,7 +105,9 @@ method for added type safety:
105
105
class Restaurant(TypedDict):
106
106
name: str
107
107
108
- sample_restaurants.restaurants.insert_one(Movie(name="Mongo's Burgers")
108
+ sample_restaurants.restaurants.insert_one(Restaurant(name="Mongo's Burgers")
109
+
110
+ .. include:: /includes/type-hints/tip-type-checkers.rst
109
111
110
112
Insert Multiple Documents
111
113
-------------------------
@@ -149,6 +151,8 @@ instances of the ``Restaurant`` class. This adds type safety to the insert opera
149
151
150
152
sample_restaurants.restaurants.insert_many(document_list)
151
153
154
+ .. include:: /includes/type-hints/tip-type-checkers.rst
155
+
152
156
Modify Insert Behavior
153
157
----------------------
154
158
@@ -233,7 +237,7 @@ calling the ``insert_many()`` method instead.
233
237
TypedDict Missing _id Key
234
238
~~~~~~~~~~~~~~~~~~~~~~~~~
235
239
236
- As discussed above, if you don't specify the ``_id`` field, {+driver-short+} automatically
240
+ If you don't specify the ``_id`` field, {+driver-short+} automatically
237
241
inserts it into the document.
238
242
You can retrieve the value of the ``_id`` field at runtime, but if you use MyPy or another
239
243
tool to perform static type-checking, it won't find the ``_id`` field in your class and
@@ -341,8 +345,10 @@ The following code example shows how to implement this solution:
341
345
342
346
.. important:: NotRequired Requires Python 3.11+
343
347
344
- The ``NotRequired`` class is available only in Python 3.11 and later.
345
- To use ``NotRequired`` in earlier versions of Python, install the ``typing_extensions``
348
+ The `NotRequired <https://docs.python.org/3/library/typing.html#typing.NotRequired>`__
349
+ class is available only in Python 3.11 and later.
350
+ To use ``NotRequired`` in earlier versions of Python, install the
351
+ `typing_extensions <https://pypi.org/project/typing-extensions/>`__
346
352
package instead.
347
353
348
354
Additional Information
0 commit comments