Skip to content

Commit 07e163f

Browse files
authoredMar 16, 2025
Fix "implicit optional", e.g. arg: int = None (#1239)
1 parent 5c9986c commit 07e163f

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed
 

‎asyncpg/connection.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,12 @@ def is_in_transaction(self):
311311
"""
312312
return self._protocol.is_in_transaction()
313313

314-
async def execute(self, query: str, *args, timeout: float=None) -> str:
314+
async def execute(
315+
self,
316+
query: str,
317+
*args,
318+
timeout: typing.Optional[float]=None,
319+
) -> str:
315320
"""Execute an SQL command (or commands).
316321
317322
This method can execute many SQL commands at once, when no arguments
@@ -358,7 +363,13 @@ async def execute(self, query: str, *args, timeout: float=None) -> str:
358363
)
359364
return status.decode()
360365

361-
async def executemany(self, command: str, args, *, timeout: float=None):
366+
async def executemany(
367+
self,
368+
command: str,
369+
args,
370+
*,
371+
timeout: typing.Optional[float]=None,
372+
):
362373
"""Execute an SQL *command* for each sequence of arguments in *args*.
363374
364375
Example:
@@ -749,7 +760,12 @@ async def fetchrow(
749760
return data[0]
750761

751762
async def fetchmany(
752-
self, query, args, *, timeout: float=None, record_class=None
763+
self,
764+
query,
765+
args,
766+
*,
767+
timeout: typing.Optional[float]=None,
768+
record_class=None,
753769
):
754770
"""Run a query for each sequence of arguments in *args*
755771
and return the results as a list of :class:`Record`.

‎asyncpg/pool.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,12 @@ async def _get_new_connection(self):
574574

575575
return con
576576

577-
async def execute(self, query: str, *args, timeout: float=None) -> str:
577+
async def execute(
578+
self,
579+
query: str,
580+
*args,
581+
timeout: Optional[float]=None,
582+
) -> str:
578583
"""Execute an SQL command (or commands).
579584
580585
Pool performs this operation using one of its connections. Other than
@@ -586,7 +591,13 @@ async def execute(self, query: str, *args, timeout: float=None) -> str:
586591
async with self.acquire() as con:
587592
return await con.execute(query, *args, timeout=timeout)
588593

589-
async def executemany(self, command: str, args, *, timeout: float=None):
594+
async def executemany(
595+
self,
596+
command: str,
597+
args,
598+
*,
599+
timeout: Optional[float]=None,
600+
):
590601
"""Execute an SQL *command* for each sequence of arguments in *args*.
591602
592603
Pool performs this operation using one of its connections. Other than

‎asyncpg/prepared_stmt.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77

88
import json
9+
import typing
910

1011
from . import connresource
1112
from . import cursor
@@ -232,7 +233,7 @@ async def fetchmany(self, args, *, timeout=None):
232233
)
233234

234235
@connresource.guarded
235-
async def executemany(self, args, *, timeout: float=None):
236+
async def executemany(self, args, *, timeout: typing.Optional[float]=None):
236237
"""Execute the statement for each sequence of arguments in *args*.
237238
238239
:param args: An iterable containing sequences of arguments.

0 commit comments

Comments
 (0)
Failed to load comments.