From 7f01904866a5b023fa71cda723cc5324383964f8 Mon Sep 17 00:00:00 2001 From: pgjones Date: Tue, 11 Oct 2022 11:19:31 +0100 Subject: [PATCH] Bugfix protocol typing As per https://github.com/python/mypy/issues/5385 the protocol AsyncGenerator method should be a `def` not `async def`. --- src/quart_db/backends/aiosqlite.py | 2 +- src/quart_db/backends/asyncpg.py | 2 +- src/quart_db/interfaces.py | 2 +- tests/test_connection.py | 5 +---- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/quart_db/backends/aiosqlite.py b/src/quart_db/backends/aiosqlite.py index 7282570..5c0b59c 100644 --- a/src/quart_db/backends/aiosqlite.py +++ b/src/quart_db/backends/aiosqlite.py @@ -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, diff --git a/src/quart_db/backends/asyncpg.py b/src/quart_db/backends/asyncpg.py index bddd435..84ddf1e 100644 --- a/src/quart_db/backends/asyncpg.py +++ b/src/quart_db/backends/asyncpg.py @@ -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, diff --git a/src/quart_db/interfaces.py b/src/quart_db/interfaces.py index 96fcc45..cc95d19 100644 --- a/src/quart_db/interfaces.py +++ b/src/quart_db/interfaces.py @@ -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, diff --git a/tests/test_connection.py b/tests/test_connection.py index 6c70c74..a0b6f00 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -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: