Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
python: Reformat with Black 22 (stable).
Anders Kaseorg1629d6bfb3e1
diff --git a/analytics/lib/fixtures.py b/analytics/lib/fixtures.pyindex fe554be68ce..b7f2bffdf11 100644--- a/analytics/lib/fixtures.py+++ b/analytics/lib/fixtures.py@@ -59,7 +59,7 @@ def generate_time_series_data()growth_base = growth ** (1.0 / (length - 1))values_no_noise = [- seasonality[i % len(seasonality)] * (growth_base ** i) for i in range(length)+ seasonality[i % len(seasonality)] * (growth_base**i) for i in range(length)]seed(random_seed)diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex d08601bc52d..e1ce174219c 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -3860,7 +3860,7 @@ class StripeWebhookEndpointTest(ZulipTestCase):"data": {"object": {"object": "checkout.session", "id": "stripe_session_id"}},}- expected_error_message = fr"Mismatch between billing system Stripe API version({STRIPE_API_VERSION}) and Stripe webhook event API version(1991-02-20)."+ expected_error_message = rf"Mismatch between billing system Stripe API version({STRIPE_API_VERSION}) and Stripe webhook event API version(1991-02-20)."with self.assertLogs("corporate.stripe", "ERROR") as error_log:self.client_post("/stripe/webhook/",diff --git a/puppet/zulip/files/nagios_plugins/zulip_postgresql/check_postgresql_replication_lag b/puppet/zulip/files/nagios_plugins/zulip_postgresql/check_postgresql_replication_lagindex 393554a9f2c..2a308b18b2a 100755--- a/puppet/zulip/files/nagios_plugins/zulip_postgresql/check_postgresql_replication_lag+++ b/puppet/zulip/files/nagios_plugins/zulip_postgresql/check_postgresql_replication_lag@@ -104,9 +104,9 @@ if is_in_recovery[0][0] == "t":report("CRITICAL", f"replica is in state {state}, not streaming")msg = f"replica is {replay_lag} bytes behind in replay of WAL logs from {primary_server}"- if replay_lag > 5 * 16 * 1024 ** 2:+ if replay_lag > 5 * 16 * 1024**2:report("CRITICAL", msg)- elif replay_lag > 16 * 1024 ** 2:+ elif replay_lag > 16 * 1024**2:report("WARNING", msg)else:report("OK", msg)@@ -135,9 +135,9 @@ else:for lag_type in ("write", "flush", "replay"):lag_bytes = lag[lag_type]msg = f"replica {client_addr} is {lag_bytes} bytes behind in {lag_type} of WAL logs"- if lag_bytes > 5 * 16 * 1024 ** 2:+ if lag_bytes > 5 * 16 * 1024**2:report("CRITICAL", msg)- elif lag_bytes > 16 * 1024 ** 2:+ elif lag_bytes > 16 * 1024**2:report("WARNING", msg)else:report("OK", msg)diff --git a/requirements/dev.txt b/requirements/dev.txtindex 24c1c8308fa..4716769f1d9 100644--- a/requirements/dev.txt+++ b/requirements/dev.txt@@ -91,9 +91,30 @@ beautifulsoup4==4.10.0 \# -r requirements/common.in# pyoembed# zulip-bots-black==21.12b0 \- --hash=sha256:77b80f693a569e2e527958459634f18df9b0ba2625ba4e0c2d5da5be42e6f2b3 \- --hash=sha256:a615e69ae185e08fdd73e4715e260e2479c861b5740057fde6e8b4e3b7dd589f+black==22.1.0 \+ --hash=sha256:07e5c049442d7ca1a2fc273c79d1aecbbf1bc858f62e8184abe1ad175c4f7cc2 \+ --hash=sha256:0e21e1f1efa65a50e3960edd068b6ae6d64ad6235bd8bfea116a03b21836af71 \+ --hash=sha256:1297c63b9e1b96a3d0da2d85d11cd9bf8664251fd69ddac068b98dc4f34f73b6 \+ --hash=sha256:228b5ae2c8e3d6227e4bde5920d2fc66cc3400fde7bcc74f480cb07ef0b570d5 \+ --hash=sha256:2d6f331c02f0f40aa51a22e479c8209d37fcd520c77721c034517d44eecf5912 \+ --hash=sha256:2ff96450d3ad9ea499fc4c60e425a1439c2120cbbc1ab959ff20f7c76ec7e866 \+ --hash=sha256:3524739d76b6b3ed1132422bf9d82123cd1705086723bc3e235ca39fd21c667d \+ --hash=sha256:35944b7100af4a985abfcaa860b06af15590deb1f392f06c8683b4381e8eeaf0 \+ --hash=sha256:373922fc66676133ddc3e754e4509196a8c392fec3f5ca4486673e685a421321 \+ --hash=sha256:5fa1db02410b1924b6749c245ab38d30621564e658297484952f3d8a39fce7e8 \+ --hash=sha256:6f2f01381f91c1efb1451998bd65a129b3ed6f64f79663a55fe0e9b74a5f81fd \+ --hash=sha256:742ce9af3086e5bd07e58c8feb09dbb2b047b7f566eb5f5bc63fd455814979f3 \+ --hash=sha256:7835fee5238fc0a0baf6c9268fb816b5f5cd9b8793423a75e8cd663c48d073ba \+ --hash=sha256:8871fcb4b447206904932b54b567923e5be802b9b19b744fdff092bd2f3118d0 \+ --hash=sha256:a7c0192d35635f6fc1174be575cb7915e92e5dd629ee79fdaf0dcfa41a80afb5 \+ --hash=sha256:b1a5ed73ab4c482208d20434f700d514f66ffe2840f63a6252ecc43a9bc77e8a \+ --hash=sha256:c8226f50b8c34a14608b848dc23a46e5d08397d009446353dad45e04af0c8e28 \+ --hash=sha256:ccad888050f5393f0d6029deea2a33e5ae371fd182a697313bdbd835d3edaf9c \+ --hash=sha256:dae63f2dbf82882fa3b2a3c49c32bffe144970a573cd68d247af6560fc493ae1 \+ --hash=sha256:e2f69158a7d120fd641d1fa9a921d898e20d52e44a74a6fbbcc570a62a6bc8ab \+ --hash=sha256:efbadd9b52c060a8fc3b9658744091cb33c31f830b3f074422ed27bad2b18e8f \+ --hash=sha256:f5660feab44c2e3cb24b2419b998846cbb01c23c7fe645fee45087efa3da2d61 \+ --hash=sha256:fdb8754b453fb15fad3f72cd9cad3e16776f0964d67cf30ebcbf10327a3777a3# via -r requirements/dev.inboto3==1.20.41 \--hash=sha256:aaddf6cf93568b734ad62fd96991775bccc7f016e93ff4e98dc1aa4f7586440c \diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2index 484ef23e7bf..a563a7ce1c7 100755--- a/scripts/lib/upgrade-zulip-stage-2+++ b/scripts/lib/upgrade-zulip-stage-2@@ -259,7 +259,7 @@ elif args.from_git:# Because `upgrade-zulip-from-git` needs to build static assets, it# is at risk of being OOM killed on systems with limited free RAM.mem_bytes = os.sysconf("SC_PAGE_SIZE") * os.sysconf("SC_PHYS_PAGES")- mem_gib = mem_bytes / (1024.0 ** 3) # e.g. 3.74+ mem_gib = mem_bytes / (1024.0**3) # e.g. 3.74# Ideally, we'd have 2 thresholds here, depending on whether the# system is running queue workers multithreaded or multiprocess.diff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.pyindex d5ec4557804..d9b6f78dd14 100644--- a/tools/lib/capitalization.py+++ b/tools/lib/capitalization.py@@ -185,7 +185,7 @@ COMPILED_IGNORED_PHRASES = []SPLIT_BOUNDARY = "?.!" # Used to split string into sentences.-SPLIT_BOUNDARY_REGEX = re.compile(fr"[{SPLIT_BOUNDARY}]")+SPLIT_BOUNDARY_REGEX = re.compile(rf"[{SPLIT_BOUNDARY}]")# Regexes which check capitalization in sentences.DISALLOWED = [diff --git a/version.py b/version.pyindex daa5572b1dd..39206446fb0 100644--- a/version.py+++ b/version.py@@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 115# historical commits sharing the same major version, in which case a# minor version bump suffices.-PROVISION_VERSION = "175.0"+PROVISION_VERSION = "176.0"diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex 7d6efa07fce..7e948500af5 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -242,7 +242,7 @@ def get_web_link_regex() -> Pattern[str]:nested_paren_chunk = nested_paren_chunk % (inner_paren_contents,)file_links = r"| (?:file://(/[^/ ]*)+/?)" if settings.ENABLE_FILE_LINKS else r""- REGEX = fr"""+ REGEX = rf"""(?<![^\s'"\(,:<]) # Start after whitespace or specified chars# (Double-negative lookbehind to allow start-of-string)(?P<url> # Main group@@ -1785,7 +1785,7 @@ def prepare_linkifier_pattern(source: str) -> str:whitespace, or opening delimiters, won't match if there are wordcharacters directly after, and saves what was matched asOUTER_CAPTURE_GROUP."""- return fr"""(?P<{BEFORE_CAPTURE_GROUP}>^|\s|['"\(,:<])(?P<{OUTER_CAPTURE_GROUP}>{source})(?P<{AFTER_CAPTURE_GROUP}>$|[^\pL\pN])"""+ return rf"""(?P<{BEFORE_CAPTURE_GROUP}>^|\s|['"\(,:<])(?P<{OUTER_CAPTURE_GROUP}>{source})(?P<{AFTER_CAPTURE_GROUP}>$|[^\pL\pN])"""# Given a regular expression pattern, linkifies groups that match itdiff --git a/zerver/lib/subdomains.py b/zerver/lib/subdomains.pyindex ab00b40c563..325990c2f42 100644--- a/zerver/lib/subdomains.py+++ b/zerver/lib/subdomains.py@@ -28,7 +28,7 @@ def get_subdomain(request: HttpRequest) -> str:def get_subdomain_from_hostname(host: str) -> str:- m = re.search(fr"\.{settings.EXTERNAL_HOST}(:\d+)?$", host)+ m = re.search(rf"\.{settings.EXTERNAL_HOST}(:\d+)?$", host)if m:subdomain = host[: m.start()]if subdomain in settings.ROOT_SUBDOMAIN_ALIASES:@@ -36,7 +36,7 @@ def get_subdomain_from_hostname(host: str) -> str:return subdomainfor subdomain, realm_host in settings.REALM_HOSTS.items():- if re.search(fr"^{realm_host}(:\d+)?$", host):+ if re.search(rf"^{realm_host}(:\d+)?$", host):return subdomainreturn Realm.SUBDOMAIN_FOR_ROOT_DOMAINdiff --git a/zerver/lib/validator.py b/zerver/lib/validator.pyindex 2b0832df8a9..78721f899d3 100644--- a/zerver/lib/validator.py+++ b/zerver/lib/validator.py@@ -530,7 +530,7 @@ def validate_todo_data(todo_data: object) -> None:# Converter functions for use with has_request_variables-def to_non_negative_int(s: str, max_int_size: int = 2 ** 32 - 1) -> int:+def to_non_negative_int(s: str, max_int_size: int = 2**32 - 1) -> int:x = int(s)if x < 0:raise ValueError("argument is negative")diff --git a/zerver/models.py b/zerver/models.pyindex 18473233eaa..673cb836462 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -247,7 +247,7 @@ class Realm(models.Model):disallow_disposable_email_addresses: bool = models.BooleanField(default=True)authentication_methods: BitHandler = BitField(flags=AUTHENTICATION_FLAGS,- default=2 ** 31 - 1,+ default=2**31 - 1,)# Allow users to access web-public streams without login. Thisdiff --git a/zerver/openapi/markdown_extension.py b/zerver/openapi/markdown_extension.pyindex 4f6ab368746..f270719785d 100644--- a/zerver/openapi/markdown_extension.py+++ b/zerver/openapi/markdown_extension.py@@ -169,7 +169,7 @@ def render_python_code_example(def render_javascript_code_example(function: str, admin_config: bool = False, **kwargs: Any) -> List[str]:- pattern = fr'^add_example\(\s*"[^"]*",\s*{re.escape(json.dumps(function))},\s*\d+,\s*async \(client, console\) => \{{\n(.*?)^(?:\}}| *\}},\n)\);$'+ pattern = rf'^add_example\(\s*"[^"]*",\s*{re.escape(json.dumps(function))},\s*\d+,\s*async \(client, console\) => \{{\n(.*?)^(?:\}}| *\}},\n)\);$'with open("zerver/openapi/javascript_examples.js") as f:m = re.search(pattern, f.read(), re.M | re.S)if m is None:diff --git a/zerver/tests/test_compatibility.py b/zerver/tests/test_compatibility.pyindex 9c77f3625f9..cd529143fba 100644--- a/zerver/tests/test_compatibility.py+++ b/zerver/tests/test_compatibility.py@@ -5,9 +5,10 @@ from zerver.lib.test_classes import ZulipTestCaseclass VersionTest(ZulipTestCase):- data = [- case.split()- for case in """+ data = (+ [+ case.split()+ for case in """1.2.3 < 1.2.41.2.3 = 1.2.31.4.1 > 1.2.3@@ -25,12 +26,14 @@ class VersionTest(ZulipTestCase):16.2.96 = 16.2.9620.0.103 > 16.2.96""".strip().split(- "\n"- )- ] + [- ["", "?", "1"],- ["", "?", "a"],- ]+ "\n"+ )+ ]+ + [+ ["", "?", "1"],+ ["", "?", "a"],+ ]+ )def test_version_lt(self) -> None:for ver1, cmp, ver2 in self.data:diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.pyindex 20d1d4ae494..5b5f389275c 100644--- a/zerver/tests/test_decorators.py+++ b/zerver/tests/test_decorators.py@@ -771,7 +771,7 @@ class ValidatorTestCase(ZulipTestCase):with self.assertRaisesRegex(ValueError, re.escape("5 is too large (max 4)")):to_non_negative_int("5", max_int_size=4)with self.assertRaisesRegex(ValueError, re.escape(f"{2**32} is too large (max {2**32-1})")):- to_non_negative_int(str(2 ** 32))+ to_non_negative_int(str(2**32))def test_check_float(self) -> None:x: Any = 5.5diff --git a/zerver/tests/test_email_change.py b/zerver/tests/test_email_change.pyindex c36a6d7c591..4eb16c3a4cf 100644--- a/zerver/tests/test_email_change.py+++ b/zerver/tests/test_email_change.py@@ -150,7 +150,7 @@ class EmailChangeTestCase(ZulipTestCase):self.assertEqual(self.email_envelope_from(email_message), settings.NOREPLY_EMAIL_ADDRESS)self.assertRegex(self.email_display_from(email_message),- fr"^Zulip Account Security <{self.TOKENIZED_NOREPLY_REGEX}>\Z",+ rf"^Zulip Account Security <{self.TOKENIZED_NOREPLY_REGEX}>\Z",)self.assertEqual(email_message.extra_headers["List-Id"], "Zulip Dev <zulip.testserver>")diff --git a/zerver/tests/test_management_commands.py b/zerver/tests/test_management_commands.pyindex 312ac9dfc78..4cba1a63fba 100644--- a/zerver/tests/test_management_commands.py+++ b/zerver/tests/test_management_commands.py@@ -381,7 +381,7 @@ class TestPasswordRestEmail(ZulipTestCase):self.assertEqual(self.email_envelope_from(outbox[0]), settings.NOREPLY_EMAIL_ADDRESS)self.assertRegex(self.email_display_from(outbox[0]),- fr"^Zulip Account Security <{self.TOKENIZED_NOREPLY_REGEX}>\Z",+ rf"^Zulip Account Security <{self.TOKENIZED_NOREPLY_REGEX}>\Z",)self.assertIn("reset your password", outbox[0].body)diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.pyindex d915464c513..fe1cb0388cf 100644--- a/zerver/tests/test_realm.py+++ b/zerver/tests/test_realm.py@@ -380,7 +380,7 @@ class RealmTest(ZulipTestCase):self.assertEqual(self.email_envelope_from(outbox[0]), settings.NOREPLY_EMAIL_ADDRESS)self.assertRegex(self.email_display_from(outbox[0]),- fr"^Zulip Account Security <{self.TOKENIZED_NOREPLY_REGEX}>\Z",+ rf"^Zulip Account Security <{self.TOKENIZED_NOREPLY_REGEX}>\Z",)self.assertIn("Reactivate your Zulip organization", outbox[0].subject)self.assertIn("Dear former administrators", outbox[0].body)diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 29ef4afd9f3..a7cc4285113 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -360,7 +360,7 @@ class PasswordResetTest(ZulipTestCase):self.assertEqual(self.email_envelope_from(message), settings.NOREPLY_EMAIL_ADDRESS)self.assertRegex(self.email_display_from(message),- fr"^Zulip Account Security <{self.TOKENIZED_NOREPLY_REGEX}>\Z",+ rf"^Zulip Account Security <{self.TOKENIZED_NOREPLY_REGEX}>\Z",)self.assertIn(f"{subdomain}.testserver", message.extra_headers["List-Id"])@@ -1036,7 +1036,7 @@ class InviteUserBase(ZulipTestCase):self.assertEqual(self.email_envelope_from(outbox[0]), settings.NOREPLY_EMAIL_ADDRESS)self.assertRegex(- self.email_display_from(outbox[0]), fr" <{self.TOKENIZED_NOREPLY_REGEX}>\Z"+ self.email_display_from(outbox[0]), rf" <{self.TOKENIZED_NOREPLY_REGEX}>\Z")self.assertEqual(outbox[0].extra_headers["List-Id"], "Zulip Dev <zulip.testserver>")diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.pyindex 33aa864467f..a8a65e92290 100644--- a/zerver/views/message_fetch.py+++ b/zerver/views/message_fetch.py@@ -291,7 +291,7 @@ class NarrowBuilder:base_stream_name = m.group(1)matching_streams = get_active_streams(self.realm).filter(- name__iregex=fr"^(un)*{self._pg_re_escape(base_stream_name)}(\.d)*$"+ name__iregex=rf"^(un)*{self._pg_re_escape(base_stream_name)}(\.d)*$")recipient_ids = [matching_stream.recipient_id for matching_stream in matching_streams]cond = column("recipient_id", Integer).in_(recipient_ids)diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.pyindex 6cd2495d3ad..fa095f86609 100644--- a/zilencer/management/commands/populate_db.py+++ b/zilencer/management/commands/populate_db.py@@ -895,7 +895,7 @@ class Command(BaseCommand):count = options["num_messages"] // threadsif i < options["num_messages"] % threads:count += 1- jobs.append((count, personals_pairs, options, random.randint(0, 10 ** 10)))+ jobs.append((count, personals_pairs, options, random.randint(0, 10**10)))for job in jobs:generate_and_send_messages(job)