Skip to content

Commit

Permalink
Bugfix protocol typing
Browse files Browse the repository at this point in the history
As per python/mypy#5385 the protocol
AsyncGenerator method should be a `def` not `async def`.
  • Loading branch information
pgjones committed Oct 11, 2022
1 parent fce2495 commit 7f01904
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/quart_db/backends/aiosqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async def fetch_val(
else:
return result[0]

async def iterate( # type: ignore[override]
async def iterate(
self,
query: str,
values: Optional[Dict[str, Any]] = None,
Expand Down
2 changes: 1 addition & 1 deletion src/quart_db/backends/asyncpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def fetch_val(
except asyncpg.exceptions.UndefinedParameterError as error:
raise UndefinedParameterError(str(error))

async def iterate( # type: ignore[override]
async def iterate(
self,
query: str,
values: Optional[Dict[str, Any]] = None,
Expand Down
2 changes: 1 addition & 1 deletion src/quart_db/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def fetch_val(self, query: str, values: Optional[Dict[str, Any]] = None) -
pass

@abstractmethod
async def iterate(
def iterate(
self,
query: str,
values: Optional[Dict[str, Any]] = None,
Expand Down
5 changes: 1 addition & 4 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ async def test_iterate(connection: Connection) -> None:
"INSERT INTO tbl (data) VALUES (:data)",
[{"data": 2}, {"data": 3}],
)
assert [2, 3] == [
result["data"]
async for result in connection.iterate("SELECT data FROM tbl") # type: ignore
]
assert [2, 3] == [result["data"] async for result in connection.iterate("SELECT data FROM tbl")]


async def test_transaction(connection: Connection) -> None:
Expand Down

0 comments on commit 7f01904

Please sign in to comment.