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 @@ -99,7 +99,9 @@ You can also create an instance of ``InsertOne`` by passing an instance of a cus
9999to the constructor. This provides additional type safety if you're using a type-checking
100100tool. The instance you pass must inherit from the ``TypedDict`` class.
101101
102- .. include:: /includes/type-hints/typeddict-availability.rst
102+ .. note:: TypedDict in Python 3.7 and Earlier
103+
104+ .. include:: /includes/type-hints/typeddict-availability.rst
103105
104106The following example constructs an ``InsertOne`` instance by using a custom
105107class for added type safety:
@@ -176,7 +178,9 @@ You can also create an instance of ``ReplaceOne`` by passing an instance of a cu
176178to the constructor. This provides additional type safety if you're using a type-checking
177179tool. The instance you pass must inherit from the ``TypedDict`` class.
178180
179- .. include:: /includes/type-hints/typeddict-availability.rst
181+ .. note:: TypedDict in Python 3.7 and Earlier
182+
183+ .. include:: /includes/type-hints/typeddict-availability.rst
180184
181185The following example constructs a ``ReplaceOne`` instance by using a custom
182186class for added type safety:
Original file line number Diff line number Diff line change @@ -64,7 +64,9 @@ You can also pass an instance of a custom class to the ``insert_one()`` method.
6464This provides additional type safety if you're using a type-checking
6565tool. The instance you pass must inherit from the ``TypedDict`` class.
6666
67- .. include:: /includes/type-hints/typeddict-availability.rst
67+ .. note:: TypedDict in Python 3.7 and Earlier
68+
69+ .. include:: /includes/type-hints/typeddict-availability.rst
6870
6971The following example passes an instance of the ``Restaurant`` class to the ``insert_one()``
7072method for added type safety:
@@ -99,7 +101,9 @@ You can also pass a list of instances of a custom class to the ``insert_many()``
99101This provides additional type safety if you're using a type-checking
100102tool. The instances you pass must inherit from the ``TypedDict`` class.
101103
102- .. include:: /includes/type-hints/typeddict-availability.rst
104+ .. note:: TypedDict in Python 3.7 and Earlier
105+
106+ .. include:: /includes/type-hints/typeddict-availability.rst
103107
104108The following example calls the ``insert_many()`` method and passes a list that contains
105109instances of the ``Restaurant`` class. This adds type safety to the insert operation.
You can’t perform that action at this time.
0 commit comments