@@ -146,9 +146,9 @@ def __init__(
146146 spec : Mapping [str , Any ] = filter or {}
147147 validate_is_mapping ("filter" , spec )
148148 if not isinstance (skip , int ):
149- raise TypeError ("skip must be an instance of int" )
149+ raise TypeError (f "skip must be an instance of int, not { type ( skip ) } . " )
150150 if not isinstance (limit , int ):
151- raise TypeError ("limit must be an instance of int" )
151+ raise TypeError (f "limit must be an instance of int, not { type ( limit ) } . " )
152152 validate_boolean ("no_cursor_timeout" , no_cursor_timeout )
153153 if no_cursor_timeout and not self ._explicit_session :
154154 warnings .warn (
@@ -171,7 +171,7 @@ def __init__(
171171 validate_boolean ("allow_partial_results" , allow_partial_results )
172172 validate_boolean ("oplog_replay" , oplog_replay )
173173 if not isinstance (batch_size , int ):
174- raise TypeError ("batch_size must be an integer" )
174+ raise TypeError (f "batch_size must be an integer, not { type ( batch_size ) } . " )
175175 if batch_size < 0 :
176176 raise ValueError ("batch_size must be >= 0" )
177177 # Only set if allow_disk_use is provided by the user, else None.
@@ -388,7 +388,7 @@ def add_option(self, mask: int) -> Cursor[_DocumentType]:
388388 cursor.add_option(2)
389389 """
390390 if not isinstance (mask , int ):
391- raise TypeError ("mask must be an int" )
391+ raise TypeError (f "mask must be an int, not { type ( mask ) } . " )
392392 self ._check_okay_to_chain ()
393393
394394 if mask & _QUERY_OPTIONS ["exhaust" ]:
@@ -408,7 +408,7 @@ def remove_option(self, mask: int) -> Cursor[_DocumentType]:
408408 cursor.remove_option(2)
409409 """
410410 if not isinstance (mask , int ):
411- raise TypeError ("mask must be an int" )
411+ raise TypeError (f "mask must be an int, not { type ( mask ) } . " )
412412 self ._check_okay_to_chain ()
413413
414414 if mask & _QUERY_OPTIONS ["exhaust" ]:
@@ -432,7 +432,7 @@ def allow_disk_use(self, allow_disk_use: bool) -> Cursor[_DocumentType]:
432432 .. versionadded:: 3.11
433433 """
434434 if not isinstance (allow_disk_use , bool ):
435- raise TypeError ("allow_disk_use must be a bool" )
435+ raise TypeError (f "allow_disk_use must be a bool, not { type ( allow_disk_use ) } . " )
436436 self ._check_okay_to_chain ()
437437
438438 self ._allow_disk_use = allow_disk_use
@@ -451,7 +451,7 @@ def limit(self, limit: int) -> Cursor[_DocumentType]:
451451 .. seealso:: The MongoDB documentation on `limit <https://dochub.mongodb.org/core/limit>`_.
452452 """
453453 if not isinstance (limit , int ):
454- raise TypeError ("limit must be an integer" )
454+ raise TypeError (f "limit must be an integer, not { type ( limit ) } . " )
455455 if self ._exhaust :
456456 raise InvalidOperation ("Can't use limit and exhaust together." )
457457 self ._check_okay_to_chain ()
@@ -479,7 +479,7 @@ def batch_size(self, batch_size: int) -> Cursor[_DocumentType]:
479479 :param batch_size: The size of each batch of results requested.
480480 """
481481 if not isinstance (batch_size , int ):
482- raise TypeError ("batch_size must be an integer" )
482+ raise TypeError (f "batch_size must be an integer, not { type ( batch_size ) } . " )
483483 if batch_size < 0 :
484484 raise ValueError ("batch_size must be >= 0" )
485485 self ._check_okay_to_chain ()
@@ -499,7 +499,7 @@ def skip(self, skip: int) -> Cursor[_DocumentType]:
499499 :param skip: the number of results to skip
500500 """
501501 if not isinstance (skip , int ):
502- raise TypeError ("skip must be an integer" )
502+ raise TypeError (f "skip must be an integer, not { type ( skip ) } . " )
503503 if skip < 0 :
504504 raise ValueError ("skip must be >= 0" )
505505 self ._check_okay_to_chain ()
@@ -520,7 +520,7 @@ def max_time_ms(self, max_time_ms: Optional[int]) -> Cursor[_DocumentType]:
520520 :param max_time_ms: the time limit after which the operation is aborted
521521 """
522522 if not isinstance (max_time_ms , int ) and max_time_ms is not None :
523- raise TypeError ("max_time_ms must be an integer or None" )
523+ raise TypeError (f "max_time_ms must be an integer or None, not { type ( max_time_ms ) } . " )
524524 self ._check_okay_to_chain ()
525525
526526 self ._max_time_ms = max_time_ms
@@ -543,7 +543,9 @@ def max_await_time_ms(self, max_await_time_ms: Optional[int]) -> Cursor[_Documen
543543 .. versionadded:: 3.2
544544 """
545545 if not isinstance (max_await_time_ms , int ) and max_await_time_ms is not None :
546- raise TypeError ("max_await_time_ms must be an integer or None" )
546+ raise TypeError (
547+ f"max_await_time_ms must be an integer or None, not { type (max_await_time_ms )} ."
548+ )
547549 self ._check_okay_to_chain ()
548550
549551 # Ignore max_await_time_ms if not tailable or await_data is False.
@@ -677,7 +679,7 @@ def max(self, spec: _Sort) -> Cursor[_DocumentType]:
677679 .. versionadded:: 2.7
678680 """
679681 if not isinstance (spec , (list , tuple )):
680- raise TypeError ("spec must be an instance of list or tuple" )
682+ raise TypeError (f "spec must be an instance of list or tuple, not { type ( spec ) } . " )
681683
682684 self ._check_okay_to_chain ()
683685 self ._max = dict (spec )
@@ -699,7 +701,7 @@ def min(self, spec: _Sort) -> Cursor[_DocumentType]:
699701 .. versionadded:: 2.7
700702 """
701703 if not isinstance (spec , (list , tuple )):
702- raise TypeError ("spec must be an instance of list or tuple" )
704+ raise TypeError (f "spec must be an instance of list or tuple, not { type ( spec ) } . " )
703705
704706 self ._check_okay_to_chain ()
705707 self ._min = dict (spec )
0 commit comments