]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Fix type hint for `Connection.notifies()`
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 26 Oct 2021 12:14:59 +0000 (13:14 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 26 Oct 2021 12:14:59 +0000 (13:14 +0100)
Close #128.

docs/news.rst
psycopg/psycopg/connection.py
psycopg/psycopg/connection_async.py

index 2dd53875bca281f38d6db0df7e027a4a44b83e9d..921fd4bc03b9a7ce68465783134b7c1af62b523a 100644 (file)
@@ -14,6 +14,7 @@ psycopg 3.0.2
 ^^^^^^^^^^^^^
 
 - Fix type hint for `sql.SQL.join()` (:ticket:`#127`).
+- Fix type hint for `Connection.notifies()` (:ticket:`#128`).
 
 
 psycopg 3.0.1
index aeca926685ff2db2024e26e8f2a48adb5d534238..8815c970c20223c3e9d34e7b342c1dcba7bd2622 100644 (file)
@@ -8,8 +8,8 @@ import logging
 import warnings
 import threading
 from types import TracebackType
-from typing import Any, Callable, cast, Dict, Generic, Iterator, List
-from typing import NamedTuple, Optional, Type, TypeVar, Union
+from typing import Any, Callable, cast, Dict, Generator, Generic, Iterator
+from typing import List, NamedTuple, Optional, Type, TypeVar, Union
 from typing import overload, TYPE_CHECKING
 from weakref import ref, ReferenceType
 from functools import partial
@@ -743,7 +743,7 @@ class Connection(BaseConnection[Row]):
         with Transaction(self, savepoint_name, force_rollback) as tx:
             yield tx
 
-    def notifies(self) -> Iterator[Notify]:
+    def notifies(self) -> Generator[Notify, None, None]:
         """
         Yield `Notify` objects as soon as they are received from the database.
         """
index 69b8bee0b7087d719f4cf44430b22a8508fc3be2..5e0b8e9a57fb176ac4a1c5fa6672ba08d28eb7d9 100644 (file)
@@ -8,8 +8,8 @@ import sys
 import asyncio
 import logging
 from types import TracebackType
-from typing import Any, AsyncIterator, Dict, Optional, Type, Union
-from typing import cast, overload, TYPE_CHECKING
+from typing import Any, AsyncGenerator, AsyncIterator, Dict, Optional
+from typing import Type, Union, cast, overload, TYPE_CHECKING
 
 from . import errors as e
 from . import waiting
@@ -275,7 +275,7 @@ class AsyncConnection(BaseConnection[Row]):
         async with tx:
             yield tx
 
-    async def notifies(self) -> AsyncIterator[Notify]:
+    async def notifies(self) -> AsyncGenerator[Notify, None]:
         while 1:
             async with self.lock:
                 ns = await self.wait(notifies(self.pgconn))