From: Denis Laxalde Date: Fri, 5 Nov 2021 10:30:26 +0000 (+0100) Subject: Make test_concurrency*.py mypy-clean X-Git-Tag: 3.0.3~3^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=423200c144cd641eff7dcf37d34c965215565208;p=thirdparty%2Fpsycopg.git Make test_concurrency*.py mypy-clean --- diff --git a/pyproject.toml b/pyproject.toml index afa3e87fb..858fcc10f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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*", diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py index f943aab5b..37e917606 100644 --- a/tests/test_concurrency.py +++ b/tests/test_concurrency.py @@ -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) diff --git a/tests/test_concurrency_async.py b/tests/test_concurrency_async.py index d5ee75120..f535d28ac 100644 --- a/tests/test_concurrency_async.py +++ b/tests/test_concurrency_async.py @@ -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()