3333from pymongo .errors import ConnectionFailure , InvalidOperation , OperationFailure
3434from pymongo .message import _CursorAddress , _GetMore , _OpMsg , _OpReply , _RawBatchGetMore
3535from pymongo .response import PinnedResponse
36- from pymongo .typings import _Address , _DocumentType
36+ from pymongo .typings import _Address , _DocumentOut , _DocumentType
3737
3838if TYPE_CHECKING :
3939 from pymongo .client_session import ClientSession
@@ -94,6 +94,7 @@ def __die(self, synchronous: bool = False) -> None:
9494 self .__killed = True
9595 if self .__id and not already_killed :
9696 cursor_id = self .__id
97+ assert self .__address is not None
9798 address = _CursorAddress (self .__address , self .__ns )
9899 else :
99100 # Skip killCursors.
@@ -219,7 +220,7 @@ def _unpack_response(
219220 codec_options : CodecOptions [Mapping [str , Any ]],
220221 user_fields : Optional [Mapping [str , Any ]] = None ,
221222 legacy_response : bool = False ,
222- ) -> List [Mapping [ str , Any ] ]:
223+ ) -> List [_DocumentOut ]:
223224 return response .unpack_response (cursor_id , codec_options , user_fields , legacy_response )
224225
225226 def _refresh (self ) -> int :
@@ -380,7 +381,7 @@ def __init__(
380381 comment ,
381382 )
382383
383- def _unpack_response (
384+ def _unpack_response ( # type: ignore[override]
384385 self ,
385386 response : Union [_OpReply , _OpMsg ],
386387 cursor_id : Optional [int ],
@@ -393,7 +394,7 @@ def _unpack_response(
393394 # OP_MSG returns firstBatch/nextBatch documents as a BSON array
394395 # Re-assemble the array of documents into a document stream
395396 _convert_raw_document_lists_to_streams (raw_response [0 ])
396- return raw_response
397+ return raw_response # type: ignore[return-value]
397398
398399 def __getitem__ (self , index : int ) -> NoReturn :
399400 raise InvalidOperation ("Cannot call __getitem__ on RawBatchCursor" )
0 commit comments