Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Refer to LoggingDatabaseConnection as a string
Browse files Browse the repository at this point in the history
I've imported it only if TYPE_CHECKING, to avoid a circular import.
  • Loading branch information
David Robertson committed May 13, 2022
1 parent 8ac10f6 commit 5ff238b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion synapse/storage/engines/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def convert_param_style(self, sql: str) -> str:
# the Sqlite engine expects to use LoggingDatabaseConnection.cursor
# instead of sqlite3.Connection.cursor: only the former takes a txn_name.
@abc.abstractmethod
def on_new_connection(self, db_conn: LoggingDatabaseConnection) -> None:
def on_new_connection(self, db_conn: "LoggingDatabaseConnection") -> None:
...

@abc.abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/engines/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def check_new_database(self, txn: Cursor) -> None:
def convert_param_style(self, sql: str) -> str:
return sql.replace("?", "%s")

def on_new_connection(self, db_conn: LoggingDatabaseConnection) -> None:
def on_new_connection(self, db_conn: "LoggingDatabaseConnection") -> None:
db_conn.set_isolation_level(self.default_isolation_level)

# Set the bytea output to escape, vs the default of hex
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/engines/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def check_new_database(self, txn: Cursor) -> None:
def convert_param_style(self, sql: str) -> str:
return sql

def on_new_connection(self, db_conn: LoggingDatabaseConnection) -> None:
def on_new_connection(self, db_conn: "LoggingDatabaseConnection") -> None:
# We need to import here to avoid an import loop.
from synapse.storage.prepare_database import prepare_database

Expand Down

0 comments on commit 5ff238b

Please sign in to comment.