Repository: mongodb-labs/pymongo-stubs (language: python)

Issue:
Update stubs for PyMongo 3.12
```
Run stubtest bson pymongo gridfs --ignore-missing-stub --whitelist tests/stubtest_whitelist/common.txt
error: pymongo.MongoClient.start_session is inconsistent, runtime argument "causal_consistency" has a default value of type None, which is incompatible with stub argument type builtins.bool
Stub: at line 89
def (self: pymongo.mongo_client.MongoClient, causal_consistency: builtins.bool =, default_transaction_options: Union[pymongo.client_session.TransactionOptions, None] =) -> pymongo.client_session.ClientSession
Runtime: at line 1888 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/mongo_client.py
def (self, causal_consistency=None, default_transaction_options=None, snapshot=False)

error: pymongo.MongoClient.start_session is inconsistent, stub does not have argument "snapshot"
Stub: at line 89
def (self: pymongo.mongo_client.MongoClient, causal_consistency: builtins.bool =, default_transaction_options: Union[pymongo.client_session.TransactionOptions, None] =) -> pymongo.client_session.ClientSession
Runtime: at line 1888 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/mongo_client.py
def (self, causal_consistency=None, default_transaction_options=None, snapshot=False)

error: pymongo.client_session.SessionOptions.__init__ is inconsistent, runtime argument "causal_consistency" has a default value of type None, which is incompatible with stub argument type builtins.bool
Stub: at line 10
def (self: pymongo.client_session.SessionOptions, causal_consistency: builtins.bool =, default_transaction_options: Union[pymongo.client_session.TransactionOptions, None] =)
Runtime: at line 176 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/client_session.py
def (self, causal_consistency=None, default_transaction_options=None, snapshot=False)

error: pymongo.client_session.SessionOptions.__init__ is inconsistent, stub does not have argument "snapshot"
Stub: at line 10
def (self: pymongo.client_session.SessionOptions, causal_consistency: builtins.bool =, default_transaction_options: Union[pymongo.client_session.TransactionOptions, None] =)
Runtime: at line 176 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/client_session.py
def (self, causal_consistency=None, default_transaction_options=None, snapshot=False)

error: pymongo.collection.Collection.aggregate_raw_batches is inconsistent, stub does not have argument "session"
Stub: at line 146
def (self: pymongo.collection.Collection, pipeline: builtins.list[typing.Mapping[builtins.str, Any]], **kwargs: Any) -> pymongo.cursor.RawBatchCursor
Runtime: at line 2503 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/collection.py
def (self, pipeline, session=None, **kwargs)

error: pymongo.database.Database.set_profiling_level is inconsistent, stub does not have argument "sample_rate"
Stub: at line 120
def (self: pymongo.database.Database, level: builtins.int, slow_ms: Union[builtins.int, None] =, session: Union[pymongo.client_session.ClientSession, None] =)
Runtime: at line 1115 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/database.py
def (self, level, slow_ms=None, session=None, sample_rate=None, filter=None)

error: pymongo.database.Database.set_profiling_level is inconsistent, stub does not have argument "filter"
Stub: at line 120
def (self: pymongo.database.Database, level: builtins.int, slow_ms: Union[builtins.int, None] =, session: Union[pymongo.client_session.ClientSession, None] =)
Runtime: at line 1115 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/database.py
def (self, level, slow_ms=None, session=None, sample_rate=None, filter=None)

error: pymongo.mongo_client.MongoClient.start_session is inconsistent, runtime argument "causal_consistency" has a default value of type None, which is incompatible with stub argument type builtins.bool
Stub: at line 89
def (self: pymongo.mongo_client.MongoClient, causal_consistency: builtins.bool =, default_transaction_options: Union[pymongo.client_session.TransactionOptions, None] =) -> pymongo.client_session.ClientSession
Runtime: at line 1888 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/mongo_client.py
def (self, causal_consistency=None, default_transaction_options=None, snapshot=False)

error: pymongo.mongo_client.MongoClient.start_session is inconsistent, stub does not have argument "snapshot"
Stub: at line 89
def (self: pymongo.mongo_client.MongoClient, causal_consistency: builtins.bool =, default_transaction_options: Union[pymongo.client_session.TransactionOptions, None] =) -> pymongo.client_session.ClientSession
Runtime: at line 1888 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/mongo_client.py
def (self, causal_consistency=None, default_transaction_options=None, snapshot=False)

error: pymongo.monitoring.CommandFailedEvent.__init__ is inconsistent, stub does not have argument "command_name"
Stub: at line 82
def (self: pymongo.monitoring.CommandFailedEvent, duration: datetime.timedelta, failure: typing.Mapping[builtins.str, Any], *args: Any)
Runtime: at line 666 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, duration, failure, command_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandFailedEvent.__init__ is inconsistent, stub does not have argument "request_id"
Stub: at line 82
def (self: pymongo.monitoring.CommandFailedEvent, duration: datetime.timedelta, failure: typing.Mapping[builtins.str, Any], *args: Any)
Runtime: at line 666 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, duration, failure, command_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandFailedEvent.__init__ is inconsistent, stub does not have argument "connection_id"
Stub: at line 82
def (self: pymongo.monitoring.CommandFailedEvent, duration: datetime.timedelta, failure: typing.Mapping[builtins.str, Any], *args: Any)
Runtime: at line 666 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, duration, failure, command_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandFailedEvent.__init__ is inconsistent, stub does not have argument "operation_id"
Stub: at line 82
def (self: pymongo.monitoring.CommandFailedEvent, duration: datetime.timedelta, failure: typing.Mapping[builtins.str, Any], *args: Any)
Runtime: at line 666 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, duration, failure, command_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandFailedEvent.__init__ is inconsistent, stub does not have argument "service_id"
Stub: at line 82
def (self: pymongo.monitoring.CommandFailedEvent, duration: datetime.timedelta, failure: typing.Mapping[builtins.str, Any], *args: Any)
Runtime: at line 666 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, duration, failure, command_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandFailedEvent.__init__ is inconsistent, runtime does not have *args argument "args"
Stub: at line 82
def (self: pymongo.monitoring.CommandFailedEvent, duration: datetime.timedelta, failure: typing.Mapping[builtins.str, Any], *args: Any)
Runtime: at line 666 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, duration, failure, command_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandStartedEvent.__init__ is inconsistent, stub does not have argument "request_id"
Stub: at line 60
def (self: pymongo.monitoring.CommandStartedEvent, command: typing.Mapping[builtins.str, Any], database_name: builtins.str, *args: Any)
Runtime: at line 568 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, command, database_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandStartedEvent.__init__ is inconsistent, stub does not have argument "connection_id"
Stub: at line 60
def (self: pymongo.monitoring.CommandStartedEvent, command: typing.Mapping[builtins.str, Any], database_name: builtins.str, *args: Any)
Runtime: at line 568 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, command, database_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandStartedEvent.__init__ is inconsistent, stub does not have argument "operation_id"
Stub: at line 60
def (self: pymongo.monitoring.CommandStartedEvent, command: typing.Mapping[builtins.str, Any], database_name: builtins.str, *args: Any)
Runtime: at line 568 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, command, database_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandStartedEvent.__init__ is inconsistent, stub does not have argument "service_id"
Stub: at line 60
def (self: pymongo.monitoring.CommandStartedEvent, command: typing.Mapping[builtins.str, Any], database_name: builtins.str, *args: Any)
Runtime: at line 568 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, command, database_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandStartedEvent.__init__ is inconsistent, runtime does not have *args argument "args"
Stub: at line 60
def (self: pymongo.monitoring.CommandStartedEvent, command: typing.Mapping[builtins.str, Any], database_name: builtins.str, *args: Any)
Runtime: at line 568 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, command, database_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.CommandSucceededEvent.__init__ is inconsistent, stub does not have argument "service_id"
Stub: at line 67
def (self: pymongo.monitoring.CommandSucceededEvent, duration: datetime.timedelta, reply: typing.Mapping[builtins.str, Any], command_name: builtins.str, request_id: builtins.int, connection_id: Tuple[builtins.str, Union[builtins.int, None]], operation_id: Union[builtins.int, None])
Runtime: at line 619 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, duration, reply, command_name, request_id, connection_id, operation_id, service_id=None)

error: pymongo.monitoring.PoolClearedEvent.__init__ is inconsistent, stub does not have argument "service_id"
Stub: at line 89
def (self: pymongo.monitoring._PoolEvent, address: Tuple[builtins.str, Union[builtins.int, None]])
Runtime: at line 749 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, address, service_id=None)

error: pymongo.monitoring._CommandEvent.__init__ is inconsistent, stub does not have argument "service_id"
Stub: at line 49
def (self: pymongo.monitoring._CommandEvent, command_name: builtins.str, request_id: builtins.int, connection_id: Tuple[builtins.str, Union[builtins.int, None]], operation_id: Union[builtins.int, None])
Runtime: at line 517 in file /opt/hostedtoolcache/Python/3.6.14/x64/lib/python3.6/site-packages/pymongo/monitoring.py
def (self, command_name, request_id, connection_id, operation_id, service_id=None)
```
https://github.com/ShaneHarvey/pymongo-stubs/runs/3402394195?check_suite_focus=true#step:5:1


Discussion / hints:

Fix patch:
diff --git a/pymongo-stubs/client_session.pyi b/pymongo-stubs/client_session.pyi
index 95f9d2c..0bb875c 100644
--- a/pymongo-stubs/client_session.pyi
+++ b/pymongo-stubs/client_session.pyi
@@ -1,4 +1,4 @@
-from typing import Any, Callable, ContextManager, Mapping, Optional, TypeVar
+from typing import Any, Callable, ContextManager, Mapping, Optional, TypeVar, Union
 
 from bson.timestamp import Timestamp
 from pymongo.mongo_client import MongoClient
@@ -8,7 +8,10 @@ from pymongo.write_concern import WriteConcern
 
 class SessionOptions:
     def __init__(
-        self, causal_consistency: bool = ..., default_transaction_options: Optional[TransactionOptions] = ...
+        self,
+        causal_consistency: Optional[bool] = ...,
+        default_transaction_options: Optional[TransactionOptions] = ...,
+        snapshot: Optional[bool] = ...,
     ) -> None: ...
     @property
     def causal_consistency(self) -> bool: ...
diff --git a/pymongo-stubs/collection.pyi b/pymongo-stubs/collection.pyi
index fe925ec..82ced5f 100644
--- a/pymongo-stubs/collection.pyi
+++ b/pymongo-stubs/collection.pyi
@@ -143,7 +143,9 @@ class Collection(common.BaseObject):
     def index_information(self, session: Optional[ClientSession] = ...) -> Dict[str, Any]: ...
     def options(self, session: Optional[ClientSession] = ...) -> Dict[str, Any]: ...
     def aggregate(self, pipeline: _Pipeline, session: Optional[ClientSession] = ..., **kwargs: Any) -> CommandCursor: ...
-    def aggregate_raw_batches(self, pipeline: _Pipeline, **kwargs: Any) -> RawBatchCursor: ...
+    def aggregate_raw_batches(
+        self, pipeline: _Pipeline, session: Optional[ClientSession] = ..., **kwargs: Any
+    ) -> RawBatchCursor: ...
     def watch(
         self,
         pipeline: Optional[_Pipeline] = ...,
diff --git a/pymongo-stubs/cursor.pyi b/pymongo-stubs/cursor.pyi
index 365c70f..1c0c900 100644
--- a/pymongo-stubs/cursor.pyi
+++ b/pymongo-stubs/cursor.pyi
@@ -38,9 +38,9 @@ class Cursor:
         max_time_ms: Optional[int] = ...,
         max: Optional[_Sort] = ...,
         min: Optional[_Sort] = ...,
-        return_key: bool = ...,
-        show_record_id: bool = ...,
-        snapshot: bool = ...,
+        return_key: Optional[bool] = ...,
+        show_record_id: Optional[bool] = ...,
+        snapshot: Optional[bool] = ...,
         comment: Any = ...,
         session: Optional[ClientSession] = ...,
         allow_disk_use: Optional[bool] = ...,
diff --git a/pymongo-stubs/database.pyi b/pymongo-stubs/database.pyi
index e957e26..6611328 100644
--- a/pymongo-stubs/database.pyi
+++ b/pymongo-stubs/database.pyi
@@ -117,7 +117,14 @@ class Database(common.BaseObject):
     ) -> Dict[str, Any]: ...
     def current_op(self, include_all: bool = ..., session: Optional[ClientSession] = ...) -> _DocumentOut: ...
     def profiling_level(self, session: Optional[ClientSession] = ...) -> int: ...
-    def set_profiling_level(self, level: int, slow_ms: Optional[int] = ..., session: Optional[ClientSession] = ...) -> None: ...
+    def set_profiling_level(
+        self,
+        level: int,
+        slow_ms: Optional[int] = ...,
+        session: Optional[ClientSession] = ...,
+        sample_rate: Optional[int] = ...,
+        filter: Optional[bool] = ...,
+    ) -> None: ...
     def profiling_info(self, session: Optional[ClientSession] = ...) -> List[Mapping[str, Any]]: ...
     def error(self) -> Optional[Mapping[str, Any]]: ...
     def last_status(self) -> Dict[str, Any]: ...
diff --git a/pymongo-stubs/mongo_client.pyi b/pymongo-stubs/mongo_client.pyi
index 6717fc5..cdbbb08 100644
--- a/pymongo-stubs/mongo_client.pyi
+++ b/pymongo-stubs/mongo_client.pyi
@@ -87,7 +87,10 @@ class MongoClient(common.BaseObject):
     def close_cursor(self, cursor_id: int, address: Optional[Tuple[str, Optional[int]]] = ...) -> None: ...
     def kill_cursors(self, cursor_ids: Sequence[int], address: Optional[Tuple[str, Optional[int]]] = ...) -> None: ...
     def start_session(
-        self, causal_consistency: bool = ..., default_transaction_options: Optional[TransactionOptions] = ...
+        self,
+        causal_consistency: Optional[bool] = ...,
+        default_transaction_options: Optional[TransactionOptions] = ...,
+        snapshot: Optional[bool] = ...,
     ) -> ClientSession: ...
     def server_info(self, session: Optional[ClientSession] = ...) -> Dict[str, Any]: ...
     def list_databases(self, session: Optional[ClientSession] = ..., **kwargs: Any) -> CommandCursor: ...
diff --git a/pymongo-stubs/monitoring.pyi b/pymongo-stubs/monitoring.pyi
index 1f0f089..a2777e6 100644
--- a/pymongo-stubs/monitoring.pyi
+++ b/pymongo-stubs/monitoring.pyi
@@ -46,7 +46,14 @@ _Document = Mapping[str, Any]
 _Address = Tuple[str, Optional[int]]
 
 class _CommandEvent:
-    def __init__(self, command_name: str, request_id: int, connection_id: _Address, operation_id: Optional[int]) -> None: ...
+    def __init__(
+        self,
+        command_name: str,
+        request_id: int,
+        connection_id: _Address,
+        operation_id: Optional[int],
+        service_id: Optional[ObjectId] = ...,
+    ) -> None: ...
     @property
     def command_name(self) -> str: ...
     @property
@@ -57,7 +64,15 @@ class _CommandEvent:
     def operation_id(self) -> Optional[int]: ...
 
 class CommandStartedEvent(_CommandEvent):
-    def __init__(self, command: _Document, database_name: str, *args: Any) -> None: ...
+    def __init__(
+        self,
+        command: _Document,
+        database_name: str,
+        request_id: int,
+        connection_id: _Address,
+        operation_id: Optional[int],
+        service_id: Optional[ObjectId] = ...,
+    ) -> None: ...
     @property
     def command(self) -> _Document: ...
     @property
@@ -72,6 +87,7 @@ class CommandSucceededEvent(_CommandEvent):
         request_id: int,
         connection_id: _Address,
         operation_id: Optional[int],
+        service_id: Optional[ObjectId] = ...,
     ) -> None: ...
     @property
     def duration_micros(self) -> int: ...
@@ -79,7 +95,16 @@ class CommandSucceededEvent(_CommandEvent):
     def reply(self) -> _Document: ...
 
 class CommandFailedEvent(_CommandEvent):
-    def __init__(self, duration: datetime.timedelta, failure: _Document, *args: Any) -> None: ...
+    def __init__(
+        self,
+        duration: datetime.timedelta,
+        failure: _Document,
+        command_name: str,
+        request_id: int,
+        connection_id: _Address,
+        operation_id: Optional[int],
+        service_id: Optional[ObjectId] = ...,
+    ) -> None: ...
     @property
     def duration_micros(self) -> int: ...
     @property
@@ -95,7 +120,9 @@ class PoolCreatedEvent(_PoolEvent):
     @property
     def options(self) -> Dict[str, Any]: ...
 
-class PoolClearedEvent(_PoolEvent): ...
+class PoolClearedEvent(_PoolEvent):
+    def __init__(self, address: _Address, service_id: Optional[ObjectId] = ...) -> None: ...
+
 class PoolClosedEvent(_PoolEvent): ...
 
 class ConnectionClosedReason:


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index cdf831a..84e98f1 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -40,7 +40,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        python-version: [3.6, 3.7, 3.8, 3.9]
+        python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
       fail-fast: false
     steps:
       - uses: actions/checkout@v2
@@ -61,7 +61,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        python-version: [3.6, 3.7, 3.8, 3.9]
+        python-version: [3.6, '3.10']
       fail-fast: false
     steps:
       - uses: actions/checkout@v2
@@ -80,9 +80,15 @@ jobs:
   test:
     name: Run test suite
     runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
+      fail-fast: false
     steps:
       - uses: actions/checkout@v2
       - uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
       - name: Start MongoDB
         uses: supercharge/mongodb-github-action@1.3.0
         with:
diff --git a/test/fail/insert_many_dict.py b/test/fail/insert_many_dict.py
index c4014c8..6e8acb6 100644
--- a/test/fail/insert_many_dict.py
+++ b/test/fail/insert_many_dict.py
@@ -1,3 +1,6 @@
 from pymongo import MongoClient
+
 client = MongoClient()
-client.test.test.insert_many({'a': 1})  # error: Dict entry 0 has incompatible type "str": "int"; expected "Mapping[str, Any]": "int"
+client.test.test.insert_many(
+    {"a": 1}
+)  # error: Dict entry 0 has incompatible type "str": "int"; expected "Mapping[str, Any]": "int"
diff --git a/test/fail/insert_one_list.py b/test/fail/insert_one_list.py
index e393b7b..7a26a3f 100644
--- a/test/fail/insert_one_list.py
+++ b/test/fail/insert_one_list.py
@@ -1,3 +1,6 @@
 from pymongo import MongoClient
+
 client = MongoClient()
-client.test.test.insert_one([{}])  # error: Argument 1 to "insert_one" of "Collection" has incompatible type "List[Dict[<nothing>, <nothing>]]"; expected "Mapping[str, Any]"
+client.test.test.insert_one(
+    [{}]
+)  # error: Argument 1 to "insert_one" of "Collection" has incompatible type "List[Dict[<nothing>, <nothing>]]"; expected "Mapping[str, Any]"
diff --git a/test/test_bson.py b/test/test_bson.py
index cb097dc..6ca773f 100644
--- a/test/test_bson.py
+++ b/test/test_bson.py
@@ -22,14 +22,14 @@
 
 class TestBSON(unittest.TestCase):
     def test_bson_encode_decode(self) -> None:
-        doc = {'_id': ObjectId()}
+        doc = {"_id": ObjectId()}
         encoded = bson.encode(doc)
         decoded = bson.decode(encoded)
         encoded = bson.encode(decoded)
         decoded = bson.decode(encoded)
         # Documents returned from decode are mutable.
-        decoded['new_field'] = 1
-        self.assertTrue(decoded['_id'].generation_time)
+        decoded["new_field"] = 1
+        self.assertTrue(decoded["_id"].generation_time)
 
 
 if __name__ == "__main__":
diff --git a/test/test_mypy_fails.py b/test/test_mypy_fails.py
index 3b0e03b..1ae1c48 100644
--- a/test/test_mypy_fails.py
+++ b/test/test_mypy_fails.py
@@ -21,7 +21,7 @@
 
 from mypy import api
 
-TEST_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'fail')
+TEST_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "fail")
 
 
 def get_tests() -> Iterable[str]:
@@ -31,7 +31,6 @@ def get_tests() -> Iterable[str]:
 
 
 class TestMypyFails(unittest.TestCase):
-
     def ensure_mypy_fails(self, filename: str) -> None:
         stdout, stderr, exit_status = api.run([filename])
         self.assertTrue(exit_status, msg=stdout)
diff --git a/test/test_pymongo.py b/test/test_pymongo.py
index cdec7c6..ab1d63d 100644
--- a/test/test_pymongo.py
+++ b/test/test_pymongo.py
@@ -29,33 +29,33 @@ class TestPymongo(unittest.TestCase):
 
     @classmethod
     def setUpClass(cls) -> None:
-        cls.client = MongoClient(
-            serverSelectionTimeoutMS=250, directConnection=False)
+        cls.client = MongoClient(serverSelectionTimeoutMS=250, directConnection=False)
         cls.coll = cls.client.test.test
         try:
-            cls.client.admin.command('ping')
+            cls.client.admin.command("ping")
         except ServerSelectionTimeoutError as exc:
-            raise unittest.SkipTest(f'Could not connect to MongoDB: {exc}')
+            raise unittest.SkipTest(f"Could not connect to MongoDB: {exc}")
 
     @classmethod
     def tearDownClass(cls) -> None:
         cls.client.close()
 
     def test_insert_find(self) -> None:
-        doc = {'my': 'doc'}
+        doc = {"my": "doc"}
         coll2 = self.client.test.test2
         result = self.coll.insert_one(doc)
-        self.assertEqual(result.inserted_id, doc['_id'])
-        retreived = self.coll.find_one({'_id': doc['_id']})
+        self.assertEqual(result.inserted_id, doc["_id"])
+        retreived = self.coll.find_one({"_id": doc["_id"]})
         if retreived:
             # Documents returned from find are mutable.
-            retreived['new_field'] = 1
+            retreived["new_field"] = 1
             result2 = coll2.insert_one(retreived)
             self.assertEqual(result2.inserted_id, result.inserted_id)
 
     def test_cursor_iterable(self) -> None:
         def to_list(iterable: Iterable[Dict[str, Any]]) -> List[Dict[str, Any]]:
             return list(iterable)
+
         self.coll.insert_one({})
         cursor = self.coll.find()
         docs = to_list(cursor)