Skip to content

Commit 2af12e6

Browse files
authored
PYTHON-3444 MyPy Errors With Version 0.981 (#1063)
1 parent 449cb8f commit 2af12e6

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

test/test_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ def auth_string(user, password):
329329
bad_user = MongoClient(auth_string("not-user", SASL_PASS))
330330
bad_pwd = MongoClient(auth_string(SASL_USER, "not-pwd"))
331331
# OperationFailure raised upon connecting.
332-
self.assertRaises(OperationFailure, bad_user.admin.command, "ping") # type: ignore[arg-type]
333-
self.assertRaises(OperationFailure, bad_pwd.admin.command, "ping") # type: ignore[arg-type]
332+
self.assertRaises(OperationFailure, bad_user.admin.command, "ping")
333+
self.assertRaises(OperationFailure, bad_pwd.admin.command, "ping")
334334

335335

336336
class TestSCRAMSHA1(IntegrationTest):

test/test_bson.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ def tzname(self, dt):
119119

120120
class TestBSON(unittest.TestCase):
121121
def assertInvalid(self, data):
122-
# Remove type ignore after: https://github.com/python/mypy/issues/13220
123-
self.assertRaises(InvalidBSON, decode, data) # type: ignore[arg-type]
122+
self.assertRaises(InvalidBSON, decode, data)
124123

125124
def check_encode_then_decode(self, doc_class=dict, decoder=decode, encoder=encode):
126125

@@ -1029,17 +1028,14 @@ def test_unicode_decode_error_handler(self):
10291028

10301029
# Ensure that strict mode raises an error.
10311030
for invalid in [invalid_key, invalid_val, invalid_both]:
1032-
# Remove type ignore after: https://github.com/python/mypy/issues/13220
10331031
self.assertRaises(
10341032
InvalidBSON,
1035-
decode, # type: ignore[arg-type]
1033+
decode,
10361034
invalid,
10371035
CodecOptions(unicode_decode_error_handler="strict"),
10381036
)
1039-
self.assertRaises(
1040-
InvalidBSON, decode, invalid, CodecOptions() # type: ignore[arg-type]
1041-
)
1042-
self.assertRaises(InvalidBSON, decode, invalid) # type: ignore[arg-type]
1037+
self.assertRaises(InvalidBSON, decode, invalid, CodecOptions())
1038+
self.assertRaises(InvalidBSON, decode, invalid)
10431039

10441040
# Test all other error handlers.
10451041
for handler in ["replace", "backslashreplace", "surrogateescape", "ignore"]:
@@ -1056,10 +1052,9 @@ def test_unicode_decode_error_handler(self):
10561052
dec = decode(enc, CodecOptions(unicode_decode_error_handler="junk"))
10571053
self.assertEqual(dec, {"keystr": "foobar"})
10581054

1059-
# Remove type ignore after: https://github.com/python/mypy/issues/13220
10601055
self.assertRaises(
10611056
InvalidBSON,
1062-
decode, # type: ignore[arg-type]
1057+
decode,
10631058
invalid_both,
10641059
CodecOptions(unicode_decode_error_handler="junk"),
10651060
)

test/test_change_stream.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,9 +1080,8 @@ def setFailPoint(self, scenario_dict):
10801080
fail_cmd = SON([("configureFailPoint", "failCommand")])
10811081
fail_cmd.update(fail_point)
10821082
client_context.client.admin.command(fail_cmd)
1083-
# Remove type ignore after: https://github.com/python/mypy/issues/13220
10841083
self.addCleanup(
1085-
client_context.client.admin.command, # type: ignore[arg-type]
1084+
client_context.client.admin.command,
10861085
"configureFailPoint",
10871086
fail_cmd["configureFailPoint"],
10881087
mode="off",

test/test_database.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,14 +604,13 @@ def test_command_max_time_ms(self):
604604
try:
605605
db = self.client.pymongo_test
606606
db.command("count", "test")
607-
# Remove type ignore after: https://github.com/python/mypy/issues/13220
608-
self.assertRaises(ExecutionTimeout, db.command, "count", "test", maxTimeMS=1) # type: ignore[arg-type]
607+
self.assertRaises(ExecutionTimeout, db.command, "count", "test", maxTimeMS=1)
609608
pipeline = [{"$project": {"name": 1, "count": 1}}]
610609
# Database command helper.
611610
db.command("aggregate", "test", pipeline=pipeline, cursor={})
612611
self.assertRaises(
613612
ExecutionTimeout,
614-
db.command, # type: ignore[arg-type]
613+
db.command,
615614
"aggregate",
616615
"test",
617616
pipeline=pipeline,

0 commit comments

Comments
 (0)