Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

ruff: Fix more of RUF010 Use conversion in f-string.

Anders Kaseorgb907ad0dcb59
diff --git a/zerver/lib/data_types.py b/zerver/lib/data_types.py
index 29318962d8a..20ee07ace75 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 98ba6f0e244..140cab15151 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 f71ede142ad..a68ea5f9d8e 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(<user for {sender.full_name}>, {repr(stream_name)}) first.
+ Please do self.subscribe(<user for {sender.full_name}>, {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 93220c90a33..1e25e8998f6 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 09c401d18c2..5dcf168b135 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:<id:{hamlet.id}><uuid:{str(hamlet.uuid)}>: "
+ f"Sending mobile push notifications for remote user 6cde5f7a-1f7e-4978-9716-49f69ebfc9fe:<id:{hamlet.id}><uuid:{hamlet.uuid}>: "
"2 via FCM devices, 1 via APNs devices",
],
)