diff --git a/zerver/lib/data_types.py b/zerver/lib/data_types.py index 29318962d8..20ee07ace7 100644 --- a/zerver/lib/data_types.py +++ b/zerver/lib/data_types.py @@ -104,7 +104,7 @@ class Equals: def schema(self, var_name: str) -> str: # Treat Equals as the degenerate case of EnumType, which # matches how we do things with OpenAPI. - return f"{var_name} in {repr([self.expected_value])}" + return f"{var_name} in {[self.expected_value]!r}" class NumberType: diff --git a/zerver/lib/queue.py b/zerver/lib/queue.py index 98ba6f0e24..140cab1515 100644 --- a/zerver/lib/queue.py +++ b/zerver/lib/queue.py @@ -94,7 +94,7 @@ class QueueClient(Generic[ChannelT], metaclass=ABCMeta): ) def _generate_ctag(self, queue_name: str) -> str: - return f"{queue_name}_{str(random.getrandbits(16))}" + return f"{queue_name}_{random.getrandbits(16)}" def _reconnect_consumer_callback(self, queue: str, consumer: Consumer[ChannelT]) -> None: self.log.info("Queue reconnecting saved consumer %r to queue %s", consumer, queue) diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index f71ede142a..a68ea5f9d8 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -1065,7 +1065,7 @@ Output: have decided to send a message to a stream without the sender being subscribed. - Please do self.subscribe(, {repr(stream_name)}) first. + Please do self.subscribe(, {stream_name!r}) first. Or choose a stream that the user is already subscribed to: @@ -1189,7 +1189,7 @@ Output: if actual_count != count: # nocoverage print("\nITEMS:\n") for index, query in enumerate(queries): - print(f"#{index + 1}\nsql: {str(query.sql)}\ntime: {query.time}\n") + print(f"#{index + 1}\nsql: {query.sql}\ntime: {query.time}\n") print(f"expected count: {count}\nactual count: {actual_count}") raise AssertionError( f""" diff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.py index 93220c90a3..1e25e8998f 100644 --- a/zerver/tests/test_openapi.py +++ b/zerver/tests/test_openapi.py @@ -366,7 +366,7 @@ so maybe we shouldn't mark it as intentionally undocumented in the URLs. The types for the request parameters in zerver/openapi/zulip.yaml do not match the types declared in the implementation of {function.__name__}.\n""" msg += "=" * 65 + "\n" - msg += "{:<10s}{:^30s}{:>10s}\n".format( + msg += "{:<10}{:^30}{:>10}\n".format( "parameter", "OpenAPI type", "function declaration type" ) msg += "=" * 65 + "\n" @@ -382,7 +382,7 @@ do not match the types declared in the implementation of {function.__name__}.\n" if element[0] == vname: fdvtype = element[1] break - msg += f"{vname:<10s}{str(opvtype):^30s}{str(fdvtype):>10s}\n" + msg += f"{vname:<10}{opvtype!s:^30}{fdvtype!s:>10}\n" raise AssertionError(msg) def check_argument_types( diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index 09c401d18c..5dcf168b13 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -399,9 +399,9 @@ class PushBouncerNotificationTest(BouncerTestCase): logger.output, [ "INFO:zilencer.views:" - f"Deduplicating push registrations for server id:{server.id} user id:{hamlet.id} uuid:{str(hamlet.uuid)} and tokens:{sorted([t.token for t in android_tokens[:]])}", + f"Deduplicating push registrations for server id:{server.id} user id:{hamlet.id} uuid:{hamlet.uuid} and tokens:{sorted(t.token for t in android_tokens)}", "INFO:zilencer.views:" - f"Sending mobile push notifications for remote user 6cde5f7a-1f7e-4978-9716-49f69ebfc9fe:: " + f"Sending mobile push notifications for remote user 6cde5f7a-1f7e-4978-9716-49f69ebfc9fe:: " "2 via FCM devices, 1 via APNs devices", ], )