From 1eee06e961bdca61646b2fb3320fd06c372bbdb2 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 29 Feb 2024 17:57:55 -0800 Subject: [PATCH] ruff: Fix E226 Missing whitespace around arithmetic operator. This is a preview rule, not yet enabled by default. Signed-off-by: Anders Kaseorg (cherry picked from commit 82a9fd927bfcad303e5967b7461c75e54dca4e7f) --- corporate/tests/test_stripe.py | 2 +- scripts/log-search | 4 ++-- zerver/tests/test_validators.py | 4 +++- zerver/webhooks/bitbucket2/tests.py | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index c395313e62..7502a6afc2 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -256,7 +256,7 @@ def normalize_fixture_data( for i, timestamp_field in enumerate(tested_timestamp_fields): # Don't use (..) notation, since the matched timestamp can easily appear in other fields pattern_translations[f'"{timestamp_field}": 1[5-9][0-9]{{8}}(?![0-9-])'] = ( - f'"{timestamp_field}": 1{i+1:02}%07d' + f'"{timestamp_field}": 1{i + 1:02}%07d' ) normalized_values: Dict[str, Dict[str, str]] = {pattern: {} for pattern in pattern_translations} diff --git a/scripts/log-search b/scripts/log-search index eb77563d7b..a67f45bc35 100755 --- a/scripts/log-search +++ b/scripts/log-search @@ -49,7 +49,7 @@ def parser() -> argparse.ArgumentParser: "-n", help="Number of log files to search", choices=range(1, access_log_retention_days + 2), - metavar=f"[1-{access_log_retention_days+1}]", + metavar=f"[1-{access_log_retention_days + 1}]", type=int, ) log_selection_options.add_argument( @@ -461,7 +461,7 @@ def print_line( gap_ms = int((logline_start - last_match_end) / timedelta(milliseconds=1)) if gap_ms > 5000: print() - print(f"========== {int(gap_ms/1000):>4} second gap ==========") + print(f"========== {int(gap_ms / 1000):>4} second gap ==========") print() elif gap_ms > 1000: print(f"============ {gap_ms:>5}ms gap ============") diff --git a/zerver/tests/test_validators.py b/zerver/tests/test_validators.py index 9892e92a97..22b45b040c 100644 --- a/zerver/tests/test_validators.py +++ b/zerver/tests/test_validators.py @@ -127,7 +127,9 @@ class ValidatorTestCase(ZulipTestCase): to_non_negative_int("x", "-1") with self.assertRaisesRegex(ValueError, re.escape("5 is too large (max 4)")): to_non_negative_int("x", "5", max_int_size=4) - with self.assertRaisesRegex(ValueError, re.escape(f"{2**32} is too large (max {2**32-1})")): + with self.assertRaisesRegex( + ValueError, re.escape(f"{2**32} is too large (max {2**32 - 1})") + ): to_non_negative_int("x", str(2**32)) def test_check_float(self) -> None: diff --git a/zerver/webhooks/bitbucket2/tests.py b/zerver/webhooks/bitbucket2/tests.py index 3d5c76a5ab..ad14169d85 100644 --- a/zerver/webhooks/bitbucket2/tests.py +++ b/zerver/webhooks/bitbucket2/tests.py @@ -25,12 +25,12 @@ class Bitbucket2HookTests(WebhookTestCase): def test_bitbucket2_on_push_commits_multiple_committers(self) -> None: commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n" - expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by Ben (2) and Tomasz (1).\n\n{commit_info*2}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" + expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by Ben (2) and Tomasz (1).\n\n{commit_info * 2}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" self.check_webhook("push_multiple_committers", TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers_with_others(self) -> None: commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n" - expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by Tomasz (4), James (3), Brendon (2) and others (1).\n\n{commit_info*9}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" + expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by Tomasz (4), James (3), Brendon (2) and others (1).\n\n{commit_info * 9}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" self.check_webhook( "push_multiple_committers_with_others", TOPIC_BRANCH_EVENTS, expected_message ) @@ -38,7 +38,7 @@ class Bitbucket2HookTests(WebhookTestCase): def test_bitbucket2_on_push_commits_multiple_committers_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches="master,development") commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n" - expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by Ben (2) and Tomasz (1).\n\n{commit_info*2}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" + expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by Ben (2) and Tomasz (1).\n\n{commit_info * 2}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" self.check_webhook("push_multiple_committers", TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers_with_others_filtered_by_branches( @@ -46,7 +46,7 @@ class Bitbucket2HookTests(WebhookTestCase): ) -> None: self.url = self.build_webhook_url(branches="master,development") commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n" - expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by Tomasz (4), James (3), Brendon (2) and others (1).\n\n{commit_info*9}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" + expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by Tomasz (4), James (3), Brendon (2) and others (1).\n\n{commit_info * 9}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" self.check_webhook( "push_multiple_committers_with_others", TOPIC_BRANCH_EVENTS, expected_message )