From 70e2ff4d67bac0f9ccbea41da81b9bb81d9f0f9f Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Wed, 12 Jul 2023 08:39:51 +0200 Subject: [PATCH] chore: bump mypy to 1.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The issue previously mentioned about '# type: ignore[arg-type]' in rows.py got resolved. The new '# type: ignore[comparison-overlap]' in test_pipeline*.py are due to https://github.com/python/mypy/issues/15509, a known regression from Mypy 1.4. We use the workaround documented in the release blog post https://mypy-lang.blogspot.com/2023/06/mypy-140-released.html (section "Narrowing Enum Values Using “==”"). --- psycopg/psycopg/rows.py | 7 +++---- psycopg/setup.cfg | 4 ++-- tests/constraints.txt | 2 +- tests/test_pipeline.py | 2 +- tests/test_pipeline_async.py | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/psycopg/psycopg/rows.py b/psycopg/psycopg/rows.py index cb28b57ac..2b240f7fb 100644 --- a/psycopg/psycopg/rows.py +++ b/psycopg/psycopg/rows.py @@ -121,8 +121,7 @@ def dict_row(cursor: "BaseCursor[Any, Any]") -> "RowMaker[DictRow]": return no_result def dict_row_(values: Sequence[Any]) -> Dict[str, Any]: - # https://github.com/python/mypy/issues/2608 - return dict(zip(names, values)) # type: ignore[arg-type] + return dict(zip(names, values)) return dict_row_ @@ -169,7 +168,7 @@ def class_row(cls: Type[T]) -> BaseRowFactory[T]: return no_result def class_row__(values: Sequence[Any]) -> T: - return cls(**dict(zip(names, values))) # type: ignore[arg-type] + return cls(**dict(zip(names, values))) return class_row__ @@ -205,7 +204,7 @@ def kwargs_row(func: Callable[..., T]) -> BaseRowFactory[T]: return no_result def kwargs_row__(values: Sequence[Any]) -> T: - return func(**dict(zip(names, values))) # type: ignore[arg-type] + return func(**dict(zip(names, values))) return kwargs_row__ diff --git a/psycopg/setup.cfg b/psycopg/setup.cfg index d8e036ffc..29e150b0e 100644 --- a/psycopg/setup.cfg +++ b/psycopg/setup.cfg @@ -66,7 +66,7 @@ pool = psycopg-pool test = anyio >= 3.6.2 - mypy >= 1.2.0 + mypy >= 1.4.1 pproxy >= 2.7 pytest >= 6.2.5 pytest-cov >= 3.0 @@ -75,7 +75,7 @@ dev = black >= 23.1.0 dnspython >= 2.1 flake8 >= 4.0 - mypy >= 1.2.0 + mypy >= 1.4.1 types-setuptools >= 57.4 wheel >= 0.37 docs = diff --git a/tests/constraints.txt b/tests/constraints.txt index 3393d458f..5ab24ed3c 100644 --- a/tests/constraints.txt +++ b/tests/constraints.txt @@ -10,7 +10,7 @@ importlib-metadata == 1.4 # From the 'test' extra anyio == 3.6.2 -mypy == 1.2.0 +mypy == 1.4.1 pproxy == 2.7.0 pytest == 6.2.5 pytest-cov == 3.0.0 diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index cfe39e07a..0a0e93fab 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -51,7 +51,7 @@ def test_pipeline_reenter(conn: psycopg.Connection[Any]) -> None: assert p2 is p1 assert p2.status == pq.PipelineStatus.ON assert conn._pipeline is None - assert p1.status == pq.PipelineStatus.OFF + assert p1.status == pq.PipelineStatus.OFF # type: ignore[comparison-overlap] def test_pipeline_broken_conn_exit(conn: psycopg.Connection[Any]) -> None: diff --git a/tests/test_pipeline_async.py b/tests/test_pipeline_async.py index 88c8d30bd..488036a7e 100644 --- a/tests/test_pipeline_async.py +++ b/tests/test_pipeline_async.py @@ -51,7 +51,7 @@ async def test_pipeline_reenter(aconn: psycopg.AsyncConnection[Any]) -> None: assert p2 is p1 assert p2.status == pq.PipelineStatus.ON assert aconn._pipeline is None - assert p1.status == pq.PipelineStatus.OFF + assert p1.status == pq.PipelineStatus.OFF # type: ignore[comparison-overlap] async def test_pipeline_broken_conn_exit(aconn: psycopg.AsyncConnection[Any]) -> None: -- 2.47.3