diff --git a/asyncpg/connection.py b/asyncpg/connection.py index 3a86466c..fe9412ab 100644 --- a/asyncpg/connection.py +++ b/asyncpg/connection.py @@ -311,7 +311,12 @@ def is_in_transaction(self): """ return self._protocol.is_in_transaction() - async def execute(self, query: str, *args, timeout: float=None) -> str: + async def execute( + self, + query: str, + *args, + timeout: typing.Optional[float]=None, + ) -> str: """Execute an SQL command (or commands). 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: ) return status.decode() - async def executemany(self, command: str, args, *, timeout: float=None): + async def executemany( + self, + command: str, + args, + *, + timeout: typing.Optional[float]=None, + ): """Execute an SQL *command* for each sequence of arguments in *args*. Example: @@ -757,7 +768,12 @@ async def fetchrow( return data[0] async def fetchmany( - self, query, args, *, timeout: float=None, record_class=None + self, + query, + args, + *, + timeout: typing.Optional[float]=None, + record_class=None, ): """Run a query for each sequence of arguments in *args* and return the results as a list of :class:`Record`. diff --git a/asyncpg/pool.py b/asyncpg/pool.py index 2e4a7b4f..5c7ea9ca 100644 --- a/asyncpg/pool.py +++ b/asyncpg/pool.py @@ -574,7 +574,12 @@ async def _get_new_connection(self): return con - async def execute(self, query: str, *args, timeout: float=None) -> str: + async def execute( + self, + query: str, + *args, + timeout: Optional[float]=None, + ) -> str: """Execute an SQL command (or commands). 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: async with self.acquire() as con: return await con.execute(query, *args, timeout=timeout) - async def executemany(self, command: str, args, *, timeout: float=None): + async def executemany( + self, + command: str, + args, + *, + timeout: Optional[float]=None, + ): """Execute an SQL *command* for each sequence of arguments in *args*. Pool performs this operation using one of its connections. Other than diff --git a/asyncpg/prepared_stmt.py b/asyncpg/prepared_stmt.py index d66a5ad3..0c2d335e 100644 --- a/asyncpg/prepared_stmt.py +++ b/asyncpg/prepared_stmt.py @@ -6,6 +6,7 @@ import json +import typing from . import connresource from . import cursor @@ -232,7 +233,7 @@ async def fetchmany(self, args, *, timeout=None): ) @connresource.guarded - async def executemany(self, args, *, timeout: float=None): + async def executemany(self, args, *, timeout: typing.Optional[float]=None): """Execute the statement for each sequence of arguments in *args*. :param args: An iterable containing sequences of arguments.