ruff: Fix E226 Missing whitespace around arithmetic operator.

This is a preview rule, not yet enabled by default.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-02-29 17:57:55 -08:00 committed by Tim Abbott
parent d748ec8d52
commit 82a9fd927b
4 changed files with 10 additions and 8 deletions

View File

@ -268,7 +268,7 @@ def normalize_fixture_data(
for i, timestamp_field in enumerate(tested_timestamp_fields): for i, timestamp_field in enumerate(tested_timestamp_fields):
# Don't use (..) notation, since the matched timestamp can easily appear in other 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-])'] = ( 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} normalized_values: Dict[str, Dict[str, str]] = {pattern: {} for pattern in pattern_translations}

View File

@ -49,7 +49,7 @@ def parser() -> argparse.ArgumentParser:
"-n", "-n",
help="Number of log files to search", help="Number of log files to search",
choices=range(1, access_log_retention_days + 2), 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, type=int,
) )
log_selection_options.add_argument( log_selection_options.add_argument(
@ -503,7 +503,7 @@ def print_line(
gap_ms = int((logline_start - last_match_end) / timedelta(milliseconds=1)) gap_ms = int((logline_start - last_match_end) / timedelta(milliseconds=1))
if gap_ms > 5000: if gap_ms > 5000:
print() print()
print(f"========== {int(gap_ms/1000):>4} second gap ==========") print(f"========== {int(gap_ms / 1000):>4} second gap ==========")
print() print()
elif gap_ms > 1000: elif gap_ms > 1000:
print(f"============ {gap_ms:>5}ms gap ============") print(f"============ {gap_ms:>5}ms gap ============")

View File

@ -124,7 +124,9 @@ class ValidatorTestCase(ZulipTestCase):
to_non_negative_int("x", "-1") to_non_negative_int("x", "-1")
with self.assertRaisesRegex(ValueError, re.escape("5 is too large (max 4)")): with self.assertRaisesRegex(ValueError, re.escape("5 is too large (max 4)")):
to_non_negative_int("x", "5", max_int_size=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)) to_non_negative_int("x", str(2**32))
def test_check_float(self) -> None: def test_check_float(self) -> None:

View File

@ -25,12 +25,12 @@ class Bitbucket2HookTests(WebhookTestCase):
def test_bitbucket2_on_push_commits_multiple_committers(self) -> None: def test_bitbucket2_on_push_commits_multiple_committers(self) -> None:
commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n" 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) self.check_webhook("push_multiple_committers", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_push_commits_multiple_committers_with_others(self) -> None: 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" 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( self.check_webhook(
"push_multiple_committers_with_others", TOPIC_BRANCH_EVENTS, expected_message "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: def test_bitbucket2_on_push_commits_multiple_committers_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches="master,development") self.url = self.build_webhook_url(branches="master,development")
commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n" 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) self.check_webhook("push_multiple_committers", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_push_commits_multiple_committers_with_others_filtered_by_branches( def test_bitbucket2_on_push_commits_multiple_committers_with_others_filtered_by_branches(
@ -46,7 +46,7 @@ class Bitbucket2HookTests(WebhookTestCase):
) -> None: ) -> None:
self.url = self.build_webhook_url(branches="master,development") self.url = self.build_webhook_url(branches="master,development")
commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n" 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( self.check_webhook(
"push_multiple_committers_with_others", TOPIC_BRANCH_EVENTS, expected_message "push_multiple_committers_with_others", TOPIC_BRANCH_EVENTS, expected_message
) )