Skip to content

Commit 43d3fa6

Browse files
authored
PYTHON-3868 add types to typings.py (#1324)
1 parent e4f1a35 commit 43d3fa6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

pymongo/typings.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@
1313
# limitations under the License.
1414

1515
"""Type aliases used by PyMongo"""
16-
from typing import TYPE_CHECKING, Any, Mapping, Optional, Sequence, Tuple, Union
16+
from typing import (
17+
TYPE_CHECKING,
18+
Any,
19+
Mapping,
20+
Optional,
21+
Sequence,
22+
Tuple,
23+
TypeVar,
24+
Union,
25+
)
1726

1827
from bson.typings import _DocumentOut, _DocumentType, _DocumentTypeArg
1928

@@ -26,8 +35,10 @@
2635
_CollationIn = Union[Mapping[str, Any], "Collation"]
2736
_Pipeline = Sequence[Mapping[str, Any]]
2837

38+
_T = TypeVar("_T")
2939

30-
def strip_optional(elem):
40+
41+
def strip_optional(elem: Optional[_T]) -> _T:
3142
"""This function is to allow us to cast all of the elements of an iterator from Optional[_T] to _T
3243
while inside a list comprehension.
3344
"""

0 commit comments

Comments
 (0)