@@ -228,7 +228,7 @@ def __init__(
228
228
read_concern or database .read_concern ,
229
229
)
230
230
if not isinstance (name , str ):
231
- raise TypeError ("name must be an instance of str" )
231
+ raise TypeError (f "name must be an instance of str, not { type ( name ) } " )
232
232
from pymongo .asynchronous .database import AsyncDatabase
233
233
234
234
if not isinstance (database , AsyncDatabase ):
@@ -2475,7 +2475,7 @@ async def _drop_index(
2475
2475
name = helpers_shared ._gen_index_name (index_or_name )
2476
2476
2477
2477
if not isinstance (name , str ):
2478
- raise TypeError ("index_or_name must be an instance of str or list" )
2478
+ raise TypeError (f "index_or_name must be an instance of str or list, not { type ( name ) } " )
2479
2479
2480
2480
cmd = {"dropIndexes" : self ._name , "index" : name }
2481
2481
cmd .update (kwargs )
@@ -3078,7 +3078,7 @@ async def rename(
3078
3078
3079
3079
"""
3080
3080
if not isinstance (new_name , str ):
3081
- raise TypeError ("new_name must be an instance of str" )
3081
+ raise TypeError (f "new_name must be an instance of str, not { type ( new_name ) } " )
3082
3082
3083
3083
if not new_name or ".." in new_name :
3084
3084
raise InvalidName ("collection names cannot be empty" )
@@ -3148,7 +3148,7 @@ async def distinct(
3148
3148
3149
3149
"""
3150
3150
if not isinstance (key , str ):
3151
- raise TypeError ("key must be an instance of str" )
3151
+ raise TypeError (f "key must be an instance of str, not { type ( key ) } " )
3152
3152
cmd = {"distinct" : self ._name , "key" : key }
3153
3153
if filter is not None :
3154
3154
if "query" in kwargs :
@@ -3196,7 +3196,7 @@ async def _find_and_modify(
3196
3196
common .validate_is_mapping ("filter" , filter )
3197
3197
if not isinstance (return_document , bool ):
3198
3198
raise ValueError (
3199
- "return_document must be ReturnDocument.BEFORE or ReturnDocument.AFTER"
3199
+ f "return_document must be ReturnDocument.BEFORE or ReturnDocument.AFTER, not { type ( return_document ) } "
3200
3200
)
3201
3201
collation = validate_collation_or_none (kwargs .pop ("collation" , None ))
3202
3202
cmd = {"findAndModify" : self ._name , "query" : filter , "new" : return_document }
0 commit comments