Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "implicit optional", e.g. arg: int = None #1239

Merged
merged 2 commits into from
Mar 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions asyncpg/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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`.
Expand Down
15 changes: 13 additions & 2 deletions asyncpg/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion asyncpg/prepared_stmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


import json
import typing

from . import connresource
from . import cursor
Expand Down Expand Up @@ -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.
Expand Down
Loading