From 992df04da67cf531dd879d7c164ac05e6f55e821 Mon Sep 17 00:00:00 2001 From: Iris <58442094+sleepyStick@users.noreply.github.com> Date: Fri, 14 Jul 2023 11:12:58 -0700 Subject: [PATCH] PYTHON-3831 remove _DocumentIn (#1308) --- bson/__init__.py | 6 +++--- bson/typings.py | 3 +-- pymongo/auth_aws.py | 4 ++-- pymongo/typings.py | 3 +-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/bson/__init__.py b/bson/__init__.py index 065e7f7ca..b6ed4ad0e 100644 --- a/bson/__init__.py +++ b/bson/__init__.py @@ -124,7 +124,7 @@ from bson.timestamp import Timestamp # Import some modules for type-checking only. if TYPE_CHECKING: - from bson.typings import _DocumentIn, _DocumentType, _ReadableBuffer + from bson.typings import _DocumentType, _ReadableBuffer try: from bson import _cbson # type: ignore[attr-defined] @@ -995,7 +995,7 @@ _CODEC_OPTIONS_TYPE_ERROR = TypeError("codec_options must be an instance of Code def encode( - document: "_DocumentIn", + document: Mapping[str, Any], check_keys: bool = False, codec_options: CodecOptions = DEFAULT_CODEC_OPTIONS, ) -> bytes: @@ -1343,7 +1343,7 @@ class BSON(bytes): @classmethod def encode( cls: Type["BSON"], - document: "_DocumentIn", + document: Mapping[str, Any], check_keys: bool = False, codec_options: CodecOptions = DEFAULT_CODEC_OPTIONS, ) -> "BSON": diff --git a/bson/typings.py b/bson/typings.py index 14a8131f6..c796c65c4 100644 --- a/bson/typings.py +++ b/bson/typings.py @@ -23,8 +23,7 @@ if TYPE_CHECKING: # Common Shared Types. -_DocumentIn = Union[MutableMapping[str, Any], "RawBSONDocument"] -_DocumentOut = _DocumentIn +_DocumentOut = Union[MutableMapping[str, Any], "RawBSONDocument"] _DocumentType = TypeVar("_DocumentType", bound=Mapping[str, Any]) _DocumentTypeArg = TypeVar("_DocumentTypeArg", bound=Mapping[str, Any]) _ReadableBuffer = Union[bytes, memoryview, "mmap", "array"] diff --git a/pymongo/auth_aws.py b/pymongo/auth_aws.py index 62aab6a21..edefd3c93 100644 --- a/pymongo/auth_aws.py +++ b/pymongo/auth_aws.py @@ -47,7 +47,7 @@ from bson.son import SON from pymongo.errors import ConfigurationError, OperationFailure if TYPE_CHECKING: - from bson.typings import _DocumentIn, _ReadableBuffer + from bson.typings import _ReadableBuffer from pymongo.auth import MongoCredential from pymongo.pool import SocketInfo @@ -58,7 +58,7 @@ class _AwsSaslContext(AwsSaslContext): # type: ignore """Return the bson.binary.Binary type.""" return Binary - def bson_encode(self, doc: _DocumentIn) -> bytes: + def bson_encode(self, doc: Mapping[str, Any]) -> bytes: """Encode a dictionary to BSON.""" return bson.encode(doc) diff --git a/pymongo/typings.py b/pymongo/typings.py index ef82114f1..e9d0ce8ce 100644 --- a/pymongo/typings.py +++ b/pymongo/typings.py @@ -15,7 +15,7 @@ """Type aliases used by PyMongo""" from typing import TYPE_CHECKING, Any, Mapping, Optional, Sequence, Tuple, Union -from bson.typings import _DocumentIn, _DocumentOut, _DocumentType, _DocumentTypeArg +from bson.typings import _DocumentOut, _DocumentType, _DocumentTypeArg if TYPE_CHECKING: from pymongo.collation import Collation @@ -36,7 +36,6 @@ def strip_optional(elem): __all__ = [ - "_DocumentIn", "_DocumentOut", "_DocumentType", "_DocumentTypeArg",