]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Make test_concurrency*.py mypy-clean
authorDenis Laxalde <denis.laxalde@dalibo.com>
Fri, 5 Nov 2021 10:30:26 +0000 (11:30 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 10 Nov 2021 01:57:39 +0000 (02:57 +0100)
pyproject.toml
tests/test_concurrency.py
tests/test_concurrency_async.py

index afa3e87fbcedf60a0570ebd168aff5eb0a8695a8..858fcc10f21b33fdfb5ab4fb369f6e58b7e37318 100644 (file)
@@ -25,6 +25,7 @@ files = [
     "tests/pq",
     "tests/scripts",
     "tests/test_adapt.py",
+    "tests/test_concurrency*.py",
     "tests/test_conninfo.py",
     "tests/test_copy*.py",
     "tests/test_dns*",
index f943aab5b7c8ed4091b5e692ae791b917ee7ead2..37e917606149f00aceb377fc9bcb2b5a326298f5 100644 (file)
@@ -10,6 +10,7 @@ import pytest
 import selectors
 import threading
 import subprocess as sp
+from typing import List
 
 import psycopg
 
@@ -40,7 +41,7 @@ def test_commit_concurrency(conn):
     # Check the condition reported in psycopg2#103
     # Because of bad status check, we commit even when a commit is already on
     # its way. We can detect this condition by the warnings.
-    notices = queue.Queue()
+    notices = queue.Queue()  # type: ignore[var-annotated]
     conn.add_notice_handler(lambda diag: notices.put(diag.message_primary))
     stop = False
 
@@ -158,7 +159,7 @@ def test_cancel(conn, retries):
 
     for retry in retries:
         with retry:
-            errors = []
+            errors: List[Exception] = []
 
             cur = conn.cursor()
             t = threading.Thread(target=canceller)
index d5ee751206c8c3e5e467fcc8add760767fea27a0..f535d28ac3cb6946be363e8c24ab36b073f700bc 100644 (file)
@@ -2,6 +2,7 @@ import time
 import pytest
 import asyncio
 from asyncio.queues import Queue
+from typing import List, Tuple
 
 import psycopg
 from psycopg._compat import create_task
@@ -14,7 +15,7 @@ async def test_commit_concurrency(aconn):
     # Check the condition reported in psycopg2#103
     # Because of bad status check, we commit even when a commit is already on
     # its way. We can detect this condition by the warnings.
-    notices = Queue()
+    notices = Queue()  # type: ignore[var-annotated]
     aconn.add_notice_handler(
         lambda diag: notices.put_nowait(diag.message_primary)
     )
@@ -81,7 +82,7 @@ async def test_notifies(aconn, dsn):
             if len(ns) >= 2:
                 await gen.aclose()
 
-    ns = []
+    ns: List[Tuple[psycopg.Notify, float]] = []
     t0 = time.time()
     workers = [notifier(), receiver()]
     await asyncio.gather(*workers)
@@ -116,7 +117,7 @@ async def test_cancel(aconn, retries):
 
     async for retry in retries:
         with retry:
-            errors = []
+            errors: List[Exception] = []
             workers = [worker(), canceller()]
 
             t0 = time.time()