This makes it easier to debug write result classes. For example, some retryable writes test was failing with:
Traceback (most recent call last): File "/Users/shane/git/mongo-python-driver/test/test_retryable_writes.py", line 126, in run_scenario "%r != %r" % (expected_result, result)) AssertionError: False is not true : {'deletedCount': 1, 'upsertedIds': {'3': 4}, 'upsertedCount': 1, 'insertedIds': {'4': 5, '2': 3, '0': 2}, 'matchedCount': 2, 'modifiedCount': 2} != <pymongo.results.BulkWriteResult object at 0x1037e5bc8>
Once we add _repr_ to the write result classes we can get:
Traceback (most recent call last): File "/Users/shane/git/mongo-python-driver/test/test_retryable_writes.py", line 126, in run_scenario "%r != %r" % (expected_result, result)) AssertionError: False is not true : {'upsertedIds': {'3': 4}, 'deletedCount': 1, 'insertedIds': {'2': 3, '4': 5, '0': 2}, 'modifiedCount': 2, 'upsertedCount': 1, 'matchedCount': 2} != BulkWriteResult({'nMatched': 2, 'nInserted': 3, 'nModified': 2, 'upserted': [{'_id': 4, 'index': 3}], 'writeErrors': [], 'nUpserted': 1, 'writeConcernErrors': [], 'nRemoved': 1}, True)
Which is much more informative.