PYTHON-3868 add types to typings.py (#1324)

This commit is contained in:
Iris 2023-07-24 16:07:12 -07:00 committed by GitHub
parent e4f1a35fd8
commit 43d3fa6774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,16 @@
# limitations under the License.
"""Type aliases used by PyMongo"""
from typing import TYPE_CHECKING, Any, Mapping, Optional, Sequence, Tuple, Union
from typing import (
TYPE_CHECKING,
Any,
Mapping,
Optional,
Sequence,
Tuple,
TypeVar,
Union,
)
from bson.typings import _DocumentOut, _DocumentType, _DocumentTypeArg
@ -26,8 +35,10 @@ _Address = Tuple[str, Optional[int]]
_CollationIn = Union[Mapping[str, Any], "Collation"]
_Pipeline = Sequence[Mapping[str, Any]]
_T = TypeVar("_T")
def strip_optional(elem):
def strip_optional(elem: Optional[_T]) -> _T:
"""This function is to allow us to cast all of the elements of an iterator from Optional[_T] to _T
while inside a list comprehension.
"""