From d33efb9bca2b30184ec360a60ff957de3fc3499c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 31 Mar 2022 14:09:24 -0500 Subject: [PATCH 1/2] PYTHON-3190 Test Failure - doctests failing cannot import name 'TypedDict' --- .evergreen/config.yml | 2 +- doc/examples/type_hints.rst | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index ef60eaf7d7..c159643fa5 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.7"] 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..676ba54360 100644 --- a/doc/examples/type_hints.rst +++ b/doc/examples/type_hints.rst @@ -97,7 +97,8 @@ You can use :py:class:`~typing.TypedDict` when using a well-defined schema for t .. 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 @@ -119,7 +120,8 @@ match a well-defined shema using :py:class:`~typing.TypedDict`. .. 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 From 3400cee872e65ff0c48328e612fc54fc8cbf7115 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Thu, 31 Mar 2022 14:29:21 -0500 Subject: [PATCH 2/2] switch to py3.8 and add notes --- .evergreen/config.yml | 2 +- doc/examples/type_hints.rst | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index c159643fa5..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.7"] + 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 676ba54360..6858e95290 100644 --- a/doc/examples/type_hints.rst +++ b/doc/examples/type_hints.rst @@ -92,7 +92,7 @@ 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:: @@ -114,7 +114,7 @@ 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:: @@ -148,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 @@ -169,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(...)``.