From 25346bde98c896f207b22c7452aaf449e322f279 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 4 Jan 2023 22:26:31 -0800 Subject: [PATCH] ruff: Fix SIM118 Use `k in d` instead of `k in d.keys()`. Signed-off-by: Anders Kaseorg --- corporate/tests/test_stripe.py | 4 +--- zerver/tests/test_home.py | 8 ++++---- zerver/worker/queue_processors.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index 9159a1fb7f..656d7c7e8a 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -268,9 +268,7 @@ def normalize_fixture_data( f'"{timestamp_field}": 1[5-9][0-9]{{8}}(?![0-9-])' ] = f'"{timestamp_field}": 1{i+1:02}%07d' - normalized_values: Dict[str, Dict[str, str]] = { - pattern: {} for pattern in pattern_translations.keys() - } + normalized_values: Dict[str, Dict[str, str]] = {pattern: {} for pattern in pattern_translations} for fixture_file in fixture_files_for_function(decorated_function): with open(fixture_file) as f: file_content = f.read() diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index 9275c63f12..b9d2d6eed2 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -263,7 +263,7 @@ class HomeTest(ZulipTestCase): page_params = self._get_page_params(result) - actual_keys = sorted(str(k) for k in page_params.keys()) + actual_keys = sorted(str(k) for k in page_params) self.assertEqual(actual_keys, self.expected_page_params_keys) @@ -284,7 +284,7 @@ class HomeTest(ZulipTestCase): "user_id", ] - realm_bots_actual_keys = sorted(str(key) for key in page_params["realm_bots"][0].keys()) + realm_bots_actual_keys = sorted(str(key) for key in page_params["realm_bots"][0]) self.assertEqual(realm_bots_actual_keys, realm_bots_expected_keys) def test_home_demo_organization(self) -> None: @@ -307,7 +307,7 @@ class HomeTest(ZulipTestCase): self.check_rendered_logged_in_app(result) page_params = self._get_page_params(result) - actual_keys = sorted(str(k) for k in page_params.keys()) + actual_keys = sorted(str(k) for k in page_params) expected_keys = self.expected_page_params_keys + [ "demo_organization_scheduled_deletion_date" ] @@ -331,7 +331,7 @@ class HomeTest(ZulipTestCase): # Check no unnecessary params are passed to spectators. page_params = self._get_page_params(result) self.assertEqual(page_params["is_spectator"], True) - actual_keys = sorted(str(k) for k in page_params.keys()) + actual_keys = sorted(str(k) for k in page_params) expected_keys = [ "apps_page_url", "bot_types", diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py index 16af740807..98695b7cc0 100644 --- a/zerver/worker/queue_processors.py +++ b/zerver/worker/queue_processors.py @@ -169,7 +169,7 @@ def get_active_worker_queues(only_test_queues: bool = False) -> List[str]: """Returns all (either test, or real) worker queues.""" return [ queue_name - for queue_name in worker_classes.keys() + for queue_name in worker_classes if bool(queue_name in test_queues) == only_test_queues ]