diff --git a/test/asynchronous/test_encryption.py b/test/asynchronous/test_encryption.py index 86172b4993..57acf5824e 100644 --- a/test/asynchronous/test_encryption.py +++ b/test/asynchronous/test_encryption.py @@ -2922,7 +2922,7 @@ async def encrypt_and_cast(i): EncryptionError, "expected matching 'min' and value type. Got range option" ): await self.client_encryption.encrypt( - 6 if cast_func is int else float(6), + 6 if cast_func is not int else float(6), key_id=self.key1_id, algorithm=Algorithm.RANGE, contention_factor=0, diff --git a/test/asynchronous/test_pooling.py b/test/asynchronous/test_pooling.py index a35ee3eecf..96b603ec10 100644 --- a/test/asynchronous/test_pooling.py +++ b/test/asynchronous/test_pooling.py @@ -346,13 +346,13 @@ async def test_no_wait_queue_timeout(self): async with pool.checkout() as s1: t = SocketGetter(self.c, pool) await t.start() - while t.state != "get_socket": # noqa: ASYNC110 + while t.state != "get_socket": # noqa: ASYNC110, RUF100 await asyncio.sleep(0.1) await asyncio.sleep(1) self.assertEqual(t.state, "get_socket") - while t.state != "connection": # noqa: ASYNC110 + while t.state != "connection": # noqa: ASYNC110, RUF100 await asyncio.sleep(0.1) self.assertEqual(t.state, "connection") @@ -521,7 +521,7 @@ async def test_pool_backpressure_preserves_existing_connections(self): await coll.insert_many([{"x": 1} for _ in range(10)]) t = SocketGetter(self.c, pool) await t.start() - while t.state != "connection": # noqa: ASYNC110 + while t.state != "connection": # noqa: ASYNC110, RUF100 await asyncio.sleep(0.1) assert not t.sock.conn_closed() diff --git a/test/asynchronous/utils_spec_runner.py b/test/asynchronous/utils_spec_runner.py index 2d573065d6..e93bab269b 100644 --- a/test/asynchronous/utils_spec_runner.py +++ b/test/asynchronous/utils_spec_runner.py @@ -160,7 +160,7 @@ async def _create_tests(self): dirname = os.path.split(dirpath)[-1] for filename in filenames: - with open(os.path.join(dirpath, filename)) as scenario_stream: # noqa: ASYNC230 + with open(os.path.join(dirpath, filename)) as scenario_stream: # noqa: ASYNC230, RUF100 # Use tz_aware=False to match how CodecOptions decodes # dates. opts = json_util.JSONOptions(tz_aware=False) diff --git a/test/test_client_metadata.py b/test/test_client_metadata.py index cbb0b1e6b0..47a37b2151 100644 --- a/test/test_client_metadata.py +++ b/test/test_client_metadata.py @@ -193,7 +193,7 @@ def test_doesnt_update_established_connections(self): ) # send initial metadata - name, version, platform, _ = self.send_ping_and_get_metadata(client, True) + name, version, platform, _metadata = self.send_ping_and_get_metadata(client, True) self.assertIsNotNone(name) self.assertIsNotNone(version) self.assertIsNotNone(platform) diff --git a/test/test_pooling.py b/test/test_pooling.py index 3a150ad34c..47266dd166 100644 --- a/test/test_pooling.py +++ b/test/test_pooling.py @@ -346,13 +346,13 @@ def test_no_wait_queue_timeout(self): with pool.checkout() as s1: t = SocketGetter(self.c, pool) t.start() - while t.state != "get_socket": + while t.state != "get_socket": # noqa: ASYNC110, RUF100 time.sleep(0.1) time.sleep(1) self.assertEqual(t.state, "get_socket") - while t.state != "connection": + while t.state != "connection": # noqa: ASYNC110, RUF100 time.sleep(0.1) self.assertEqual(t.state, "connection") @@ -519,7 +519,7 @@ def test_pool_backpressure_preserves_existing_connections(self): coll.insert_many([{"x": 1} for _ in range(10)]) t = SocketGetter(self.c, pool) t.start() - while t.state != "connection": + while t.state != "connection": # noqa: ASYNC110, RUF100 time.sleep(0.1) assert not t.sock.conn_closed() diff --git a/test/utils_spec_runner.py b/test/utils_spec_runner.py index f92533a9d4..5c63cd08c4 100644 --- a/test/utils_spec_runner.py +++ b/test/utils_spec_runner.py @@ -160,7 +160,7 @@ def _create_tests(self): dirname = os.path.split(dirpath)[-1] for filename in filenames: - with open(os.path.join(dirpath, filename)) as scenario_stream: # noqa: RUF100 + with open(os.path.join(dirpath, filename)) as scenario_stream: # noqa: ASYNC230, RUF100 # Use tz_aware=False to match how CodecOptions decodes # dates. opts = json_util.JSONOptions(tz_aware=False) diff --git a/tools/synchro.py b/tools/synchro.py index a8af3876eb..6e641a9218 100644 --- a/tools/synchro.py +++ b/tools/synchro.py @@ -171,22 +171,14 @@ if not Path.exists(Path(_gridfs_dest_base)): Path.mkdir(Path(_gridfs_dest_base)) -async_files = [ - _pymongo_base + str(f) - for f in Path.iterdir(Path(_pymongo_base)) - if (Path(_pymongo_base) / f).is_file() -] +async_files = [_pymongo_base + f.name for f in Path(_pymongo_base).iterdir() if f.is_file()] -gridfs_files = [ - _gridfs_base + str(f) - for f in Path.iterdir(Path(_gridfs_base)) - if (Path(_gridfs_base) / f).is_file() -] +gridfs_files = [_gridfs_base + f.name for f in Path(_gridfs_base).iterdir() if f.is_file()] def async_only_test(f: Path) -> bool: """Return True for async tests that should not be converted to sync.""" - return str(f) in [ + return f.name in [ "test_locks.py", "test_concurrency.py", "test_async_cancellation.py", @@ -197,9 +189,9 @@ def async_only_test(f: Path) -> bool: test_files = [ - _test_base + str(f) - for f in Path.iterdir(Path(_test_base)) - if (Path(_test_base) / f).is_file() and not async_only_test(f) + _test_base + f.name + for f in Path(_test_base).iterdir() + if f.is_file() and not async_only_test(f) ] # Add each asynchronized test here as part of the converting PR @@ -453,15 +445,11 @@ def main() -> None: unasync_directory(test_files, _test_base, _test_dest_base, replacements) sync_files = [ - _pymongo_dest_base + str(f) - for f in Path.iterdir(Path(_pymongo_dest_base)) - if (Path(_pymongo_dest_base) / f).is_file() + _pymongo_dest_base + f.name for f in Path(_pymongo_dest_base).iterdir() if f.is_file() ] sync_gridfs_files = [ - _gridfs_dest_base + str(f) - for f in Path.iterdir(Path(_gridfs_dest_base)) - if (Path(_gridfs_dest_base) / f).is_file() + _gridfs_dest_base + f.name for f in Path(_gridfs_dest_base).iterdir() if f.is_file() ] sync_test_files = [ _test_dest_base + f for f in converted_tests if (Path(_test_dest_base) / f).is_file()