Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit 77d9b8a

Browse files
authored
Fix the type-hints using more standard mode (#526)
1 parent 6b0c767 commit 77d9b8a

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

databases/backends/aiopg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class AiopgConnection(ConnectionBackend):
104104
def __init__(self, database: AiopgBackend, dialect: Dialect):
105105
self._database = database
106106
self._dialect = dialect
107-
self._connection = None # type: typing.Optional[aiopg.Connection]
107+
self._connection: typing.Optional[aiopg.Connection] = None
108108

109109
async def acquire(self) -> None:
110110
assert self._connection is None, "Connection is already acquired"

databases/backends/asyncmy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class AsyncMyConnection(ConnectionBackend):
9292
def __init__(self, database: AsyncMyBackend, dialect: Dialect):
9393
self._database = database
9494
self._dialect = dialect
95-
self._connection = None # type: typing.Optional[asyncmy.Connection]
95+
self._connection: typing.Optional[asyncmy.Connection] = None
9696

9797
async def acquire(self) -> None:
9898
assert self._connection is None, "Connection is already acquired"

databases/backends/mysql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class MySQLConnection(ConnectionBackend):
9292
def __init__(self, database: MySQLBackend, dialect: Dialect):
9393
self._database = database
9494
self._dialect = dialect
95-
self._connection = None # type: typing.Optional[aiomysql.Connection]
95+
self._connection: typing.Optional[aiomysql.Connection] = None
9696

9797
async def acquire(self) -> None:
9898
assert self._connection is None, "Connection is already acquired"

databases/backends/postgres.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _get_dialect(self) -> Dialect:
4545
def _get_connection_kwargs(self) -> dict:
4646
url_options = self._database_url.options
4747

48-
kwargs = {} # type: typing.Dict[str, typing.Any]
48+
kwargs: typing.Dict[str, typing.Any] = {}
4949
min_size = url_options.get("min_size")
5050
max_size = url_options.get("max_size")
5151
ssl = url_options.get("ssl")
@@ -162,7 +162,7 @@ class PostgresConnection(ConnectionBackend):
162162
def __init__(self, database: PostgresBackend, dialect: Dialect):
163163
self._database = database
164164
self._dialect = dialect
165-
self._connection = None # type: typing.Optional[asyncpg.connection.Connection]
165+
self._connection: typing.Optional[asyncpg.connection.Connection] = None
166166

167167
async def acquire(self) -> None:
168168
assert self._connection is None, "Connection is already acquired"
@@ -305,9 +305,7 @@ def raw_connection(self) -> asyncpg.connection.Connection:
305305
class PostgresTransaction(TransactionBackend):
306306
def __init__(self, connection: PostgresConnection):
307307
self._connection = connection
308-
self._transaction = (
309-
None
310-
) # type: typing.Optional[asyncpg.transaction.Transaction]
308+
self._transaction: typing.Optional[asyncpg.transaction.Transaction] = None
311309

312310
async def start(
313311
self, is_root: bool, extra_options: typing.Dict[typing.Any, typing.Any]

databases/backends/sqlite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class SQLiteConnection(ConnectionBackend):
8080
def __init__(self, pool: SQLitePool, dialect: Dialect):
8181
self._pool = pool
8282
self._dialect = dialect
83-
self._connection = None # type: typing.Optional[aiosqlite.Connection]
83+
self._connection: typing.Optional[aiosqlite.Connection] = None
8484

8585
async def acquire(self) -> None:
8686
assert self._connection is None, "Connection is already acquired"

databases/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ def __init__(
6464
self._backend = backend_cls(self.url, **self.options)
6565

6666
# Connections are stored as task-local state.
67-
self._connection_context = ContextVar("connection_context") # type: ContextVar
67+
self._connection_context: ContextVar = ContextVar("connection_context")
6868

6969
# When `force_rollback=True` is used, we use a single global
7070
# connection, within a transaction that always rolls back.
71-
self._global_connection = None # type: typing.Optional[Connection]
72-
self._global_transaction = None # type: typing.Optional[Transaction]
71+
self._global_connection: typing.Optional[Connection] = None
72+
self._global_transaction: typing.Optional[Transaction] = None
7373

7474
async def connect(self) -> None:
7575
"""
@@ -223,7 +223,7 @@ def __init__(self, backend: DatabaseBackend) -> None:
223223
self._connection_counter = 0
224224

225225
self._transaction_lock = asyncio.Lock()
226-
self._transaction_stack = [] # type: typing.List[Transaction]
226+
self._transaction_stack: typing.List[Transaction] = []
227227

228228
self._query_lock = asyncio.Lock()
229229

0 commit comments

Comments
 (0)