File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change 1- The examples in this section use the ``TypedDict `` class from the ``typing `` module. This
2- module is available only in Python 3.8 and later. To use the ``TypedDict `` class in
1+ The ``TypedDict `` class is in the ``typing `` module, which
2+ is available only in Python 3.8 and later. To use the ``TypedDict `` class in
33earlier versions of Python, install the ``typing_extensions `` package.
Original file line number Diff line number Diff line change @@ -238,7 +238,9 @@ the class name. The class can be one of the following types:
238238 parameter, you must also include the class in a type hint for your ``CodecOptions``
239239 object.
240240
241- .. include:: /includes/type-hints/typeddict-availability.rst
241+ .. note:: TypedDict in Python 3.7 and Earlier
242+
243+ .. include:: /includes/type-hints/typeddict-availability.rst
242244
243245The following example decodes the BSON returned by the ``ping`` command to instances
244246of the ``RawBSONDocument`` class:
Original file line number Diff line number Diff line change @@ -69,7 +69,9 @@ You can also create an instance of ``InsertOne`` by passing an instance of a cus
6969to the constructor. This provides additional type safety if you're using a type-checking
7070tool. The instance you pass must inherit from the ``TypedDict`` class.
7171
72- .. include:: /includes/type-hints/typeddict-availability.rst
72+ .. note:: TypedDict in Python 3.7 and Earlier
73+
74+ .. include:: /includes/type-hints/typeddict-availability.rst
7375
7476The following example constructs an ``InsertOne`` instance by using a custom
7577class for added type safety:
@@ -141,7 +143,9 @@ You can also create an instance of ``ReplaceOne`` by passing an instance of a cu
141143to the constructor. This provides additional type safety if you're using a type-checking
142144tool. The instance you pass must inherit from the ``TypedDict`` class.
143145
144- .. include:: /includes/type-hints/typeddict-availability.rst
146+ .. note:: TypedDict in Python 3.7 and Earlier
147+
148+ .. include:: /includes/type-hints/typeddict-availability.rst
145149
146150The following example constructs a ``ReplaceOne`` instance by using a custom
147151class for added type safety:
Original file line number Diff line number Diff line change @@ -92,7 +92,9 @@ You can also pass an instance of a custom class to the ``insert_one()`` method.
9292This provides additional type safety if you're using a type-checking
9393tool. The instance you pass must inherit from the ``TypedDict`` class.
9494
95- .. include:: /includes/type-hints/typeddict-availability.rst
95+ .. note:: TypedDict in Python 3.7 and Earlier
96+
97+ .. include:: /includes/type-hints/typeddict-availability.rst
9698
9799The following example passes an instance of the ``Restaurant`` class to the ``insert_one()``
98100method for added type safety:
@@ -127,7 +129,9 @@ You can also pass a list of instances of a custom class to the ``insert_many()``
127129This provides additional type safety if you're using a type-checking
128130tool. The instances you pass must inherit from the ``TypedDict`` class.
129131
130- .. include:: /includes/type-hints/typeddict-availability.rst
132+ .. note:: TypedDict in Python 3.7 and Earlier
133+
134+ .. include:: /includes/type-hints/typeddict-availability.rst
131135
132136The following example calls the ``insert_many()`` method and passes a list that contains
133137instances of the ``Restaurant`` class. This adds type safety to the insert operation.
You can’t perform that action at this time.
0 commit comments