Skip to content

Commit a809b3c

Browse files
authored
PYTHON-3190 Test Failure - doctests failing cannot import name 'TypedDict' (#917)
1 parent 1d6914f commit a809b3c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

.evergreen/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,7 @@ buildvariants:
25062506
- matrix_name: "tests-doctests"
25072507
matrix_spec:
25082508
platform: ubuntu-18.04
2509-
python-version: ["3.6"]
2509+
python-version: ["3.8"]
25102510
display_name: "Doctests ${python-version} ${platform}"
25112511
tasks:
25122512
- name: "doctests"

doc/examples/type_hints.rst

+8-6
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ Note that when using :class:`~bson.son.SON`, the key and value types must be giv
9292
Typed 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

115116
While 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.
150152
For :py:class:`~typing.TypedDict`, use the form: ``options: CodecOptions[MyTypedDict] = CodecOptions(...)``.
151153

152154
Typed 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.
171173
For :py:class:`~typing.TypedDict`, use the form: ``options: CodecOptions[MyTypedDict] = CodecOptions(...)``.
172174

173175

0 commit comments

Comments
 (0)