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

This commit is contained in:
Steven Silvester 2022-03-31 16:11:20 -05:00 committed by GitHub
parent 1d6914f749
commit a809b3c005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -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"

View File

@ -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
@ -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
@ -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
@ -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(...)``.