diff --git a/synapse/storage/data_stores/main/stream.py b/synapse/storage/data_stores/main/stream.py
index a20c3d1012f85dc00bdbbd2d46f7565360a70001..056b25b13a3fecd2b70b577d20b7e4b03e77816f 100644
--- a/synapse/storage/data_stores/main/stream.py
+++ b/synapse/storage/data_stores/main/stream.py
@@ -536,14 +536,15 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
             Deferred[(int, int, str)]:
                 (stream ordering, topological ordering, event_id)
         """
+
         def _f(txn):
             sql = (
-              "SELECT stream_ordering, topological_ordering, event_id"
-              " FROM events"
-              " WHERE room_id = ? AND stream_ordering <= ?"
-              " AND NOT outlier"
-              " ORDER BY stream_ordering DESC"
-              " LIMIT 1"
+                "SELECT stream_ordering, topological_ordering, event_id"
+                " FROM events"
+                " WHERE room_id = ? AND stream_ordering <= ?"
+                " AND NOT outlier"
+                " ORDER BY stream_ordering DESC"
+                " LIMIT 1"
             )
             txn.execute(sql, (room_id, stream_ordering))
             return txn.fetchone()