Skip to content

Commit f9a097a

Browse files
committed
fix typing
1 parent a17f6ef commit f9a097a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/mockupdb/test_client_metadata.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def setUp(self):
4444
self.server = MockupDB()
4545
# there are two handshake requests, i believe one is from the monitor, and the other is from the client
4646
self.monitor_handshake = False
47-
self.handshake_req = None
47+
self.handshake_req: Optional[dict] = None
4848

4949
def respond(r):
5050
# Only save the very first request from the driver.
@@ -60,7 +60,7 @@ def respond(r):
6060
self.addCleanup(self.server.stop)
6161

6262
def check_metadata_added(
63-
self, add_name: Optional[str], add_version: Optional[str], add_platform: Optional[str]
63+
self, add_name: str, add_version: Optional[str], add_platform: Optional[str]
6464
) -> None:
6565
client = MongoClient(
6666
"mongodb://" + self.server.address_string,
@@ -84,6 +84,7 @@ def check_metadata_added(
8484
# make sure new metadata is being sent
8585
self.handshake_req = None
8686
client.admin.command("ping")
87+
# self.assertIsNotNone(self.handshake_req)
8788
new_metadata = _get_handshake_driver_info(self.handshake_req)
8889

8990
self.assertEqual(
@@ -144,8 +145,10 @@ def test_doesnt_update_established_connections(self):
144145
add_name, add_version, add_platform = "framework", "2.0", "Framework Platform"
145146
client._append_metadata(DriverInfo(add_name, add_version, add_platform))
146147
# check new data isn't sent
147-
self.handshake_req = None
148+
self.handshake_req: Optional[dict] = None
148149
client.admin.command("ping")
150+
self.assertIsNotNone(self.handshake_req)
151+
assert self.handshake_req is not None # so mypy knows that it's not None
149152
self.assertNotIn("client", self.handshake_req)
150153
self.assertEqual(listener.event_count(ConnectionClosedEvent), 0)
151154

0 commit comments

Comments
 (0)