Skip to content

PYTHON-3190 Test Failure - doctests failing cannot import name 'TypedDict' #917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,7 @@ buildvariants:
- matrix_name: "tests-doctests"
matrix_spec:
platform: ubuntu-18.04
python-version: ["3.6"]
python-version: ["3.8"]
display_name: "Doctests ${python-version} ${platform}"
tasks:
- name: "doctests"
Expand Down
14 changes: 8 additions & 6 deletions doc/examples/type_hints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ Note that when using :class:`~bson.son.SON`, the key and value types must be giv
Typed Collection
----------------

You can use :py:class:`~typing.TypedDict` when using a well-defined schema for the data in a :class:`~pymongo.collection.Collection`:
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`:

.. doctest::

>>> from typing import TypedDict
>>> from pymongo import MongoClient, Collection
>>> from pymongo import MongoClient
>>> from pymongo.collection import Collection
>>> class Movie(TypedDict):
... name: str
... year: int
Expand All @@ -113,13 +114,14 @@ Typed Database
--------------

While less common, you could specify that the documents in an entire database
match a well-defined shema using :py:class:`~typing.TypedDict`.
match a well-defined shema using :py:class:`~typing.TypedDict` (Python 3.8+).


.. doctest::

>>> from typing import TypedDict
>>> from pymongo import MongoClient, Database
>>> from pymongo import MongoClient
>>> from pymongo.database import Database
>>> class Movie(TypedDict):
... name: str
... year: int
Expand All @@ -146,7 +148,7 @@ When using the :meth:`~pymongo.database.Database.command`, you can specify the d
>>> result = client.admin.command("ping", codec_options=options)
>>> assert isinstance(result, RawBSONDocument)

Custom :py:class:`collections.abc.Mapping` subclasses and :py:class:`~typing.TypedDict` are also supported.
Custom :py:class:`collections.abc.Mapping` subclasses and :py:class:`~typing.TypedDict` (Python 3.8+) are also supported.
For :py:class:`~typing.TypedDict`, use the form: ``options: CodecOptions[MyTypedDict] = CodecOptions(...)``.

Typed BSON Decoding
Expand All @@ -167,7 +169,7 @@ You can specify the document type returned by :mod:`bson` decoding functions by
>>> rt_document = decode(bsonbytes, codec_options=options)
>>> assert rt_document.foo() == "bar"

:class:`~bson.raw_bson.RawBSONDocument` and :py:class:`~typing.TypedDict` are also supported.
:class:`~bson.raw_bson.RawBSONDocument` and :py:class:`~typing.TypedDict` (Python 3.8+) are also supported.
For :py:class:`~typing.TypedDict`, use the form: ``options: CodecOptions[MyTypedDict] = CodecOptions(...)``.


Expand Down