PYTHON-3831 remove _DocumentIn (#1308)

This commit is contained in:
Iris 2023-07-14 11:12:58 -07:00 committed by GitHub
parent 62a4d12239
commit 992df04da6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 9 deletions

View File

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

View File

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

View File

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

View File

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