diff --git a/.evergreen/config.yml b/.evergreen/config.yml index ef60eaf7d7..a6d9375f26 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -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" diff --git a/doc/examples/type_hints.rst b/doc/examples/type_hints.rst index 029761bc75..6858e95290 100644 --- a/doc/examples/type_hints.rst +++ b/doc/examples/type_hints.rst @@ -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(...)``.