zerver/lib: Use python 3 syntax for typing.

Split by tabbott from a larger commit; this covers a batch of files
with no open PRs touching them.
This commit is contained in:
rht
2017-11-05 11:15:10 +01:00
committed by Tim Abbott
parent 73d0f1db81
commit 561ba33f69
15 changed files with 119 additions and 206 deletions

View File

@@ -6,16 +6,13 @@ import sqlalchemy
# This is a Pool that doesn't close connections. Therefore it can be used with
# existing Django database connections.
class NonClosingPool(sqlalchemy.pool.NullPool):
def status(self):
# type: () -> str
def status(self) -> str:
return "NonClosingPool"
def _do_return_conn(self, conn):
# type: (sqlalchemy.engine.base.Connection) -> None
def _do_return_conn(self, conn: sqlalchemy.engine.base.Connection) -> None:
pass
def recreate(self):
# type: () -> NonClosingPool
def recreate(self) -> 'NonClosingPool':
return self.__class__(creator=self._creator,
recycle=self._recycle,
use_threadlocal=self._use_threadlocal,
@@ -25,12 +22,10 @@ class NonClosingPool(sqlalchemy.pool.NullPool):
_dispatch=self.dispatch)
sqlalchemy_engine = None
def get_sqlalchemy_connection():
# type: () -> sqlalchemy.engine.base.Connection
def get_sqlalchemy_connection() -> sqlalchemy.engine.base.Connection:
global sqlalchemy_engine
if sqlalchemy_engine is None:
def get_dj_conn():
# type: () -> TimeTrackingConnection
def get_dj_conn() -> TimeTrackingConnection:
connection.ensure_connection()
return connection.connection
sqlalchemy_engine = sqlalchemy.create_engine('postgresql://',