@@ -92,12 +92,13 @@ Note that when using :class:`~bson.son.SON`, the key and value types must be giv
9292Typed Collection
9393----------------
9494
95- You can use :py:class: `~typing.TypedDict ` when using a well-defined schema for the data in a :class: `~pymongo.collection.Collection `:
95+ You can use :py:class: `~typing.TypedDict ` (Python 3.8+) when using a well-defined schema for the data in a :class: `~pymongo.collection.Collection `:
9696
9797.. doctest ::
9898
9999 >>> from typing import TypedDict
100- >>> from pymongo import MongoClient, Collection
100+ >>> from pymongo import MongoClient
101+ >>> from pymongo.collection import Collection
101102 >>> class Movie (TypedDict ):
102103 ... name: str
103104 ... year: int
@@ -113,13 +114,14 @@ Typed Database
113114--------------
114115
115116While less common, you could specify that the documents in an entire database
116- match a well-defined shema using :py:class: `~typing.TypedDict `.
117+ match a well-defined shema using :py:class: `~typing.TypedDict ` (Python 3.8+) .
117118
118119
119120.. doctest ::
120121
121122 >>> from typing import TypedDict
122- >>> from pymongo import MongoClient, Database
123+ >>> from pymongo import MongoClient
124+ >>> from pymongo.database import Database
123125 >>> class Movie (TypedDict ):
124126 ... name: str
125127 ... year: int
@@ -146,7 +148,7 @@ When using the :meth:`~pymongo.database.Database.command`, you can specify the d
146148 >>> result = client.admin.command(" ping" , codec_options = options)
147149 >>> assert isinstance (result, RawBSONDocument)
148150
149- Custom :py:class: `collections.abc.Mapping ` subclasses and :py:class: `~typing.TypedDict ` are also supported.
151+ Custom :py:class: `collections.abc.Mapping ` subclasses and :py:class: `~typing.TypedDict ` (Python 3.8+) are also supported.
150152For :py:class: `~typing.TypedDict `, use the form: ``options: CodecOptions[MyTypedDict] = CodecOptions(...) ``.
151153
152154Typed BSON Decoding
@@ -167,7 +169,7 @@ You can specify the document type returned by :mod:`bson` decoding functions by
167169 >>> rt_document = decode(bsonbytes, codec_options = options)
168170 >>> assert rt_document.foo() == " bar"
169171
170- :class: `~bson.raw_bson.RawBSONDocument ` and :py:class: `~typing.TypedDict ` are also supported.
172+ :class: `~bson.raw_bson.RawBSONDocument ` and :py:class: `~typing.TypedDict ` (Python 3.8+) are also supported.
171173For :py:class: `~typing.TypedDict `, use the form: ``options: CodecOptions[MyTypedDict] = CodecOptions(...) ``.
172174
173175
0 commit comments