From: Denis Laxalde Date: Sat, 11 Feb 2023 09:51:35 +0000 (+0100) Subject: chore: upgrade to mypy 1.0.0 X-Git-Tag: pool-3.1.7~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=104d435b225ee1f63cfefa223d36815de78b8414;p=thirdparty%2Fpsycopg.git chore: upgrade to mypy 1.0.0 Some "type: ignore" no longer needed, some need a different kind. --- diff --git a/psycopg/psycopg/pq/__init__.py b/psycopg/psycopg/pq/__init__.py index d5180b1b6..0048ebbf1 100644 --- a/psycopg/psycopg/pq/__init__.py +++ b/psycopg/psycopg/pq/__init__.py @@ -86,7 +86,7 @@ def import_from_libpq() -> None: # Pure Python implementation, slow and requires the system libpq installed. if not module and (not impl or impl == "python"): try: - from . import pq_ctypes as module # type: ignore[no-redef] + from . import pq_ctypes as module # type: ignore[assignment] except Exception as e: handle_error("python", e) diff --git a/psycopg/psycopg/types/numeric.py b/psycopg/psycopg/types/numeric.py index 8e92392a3..0b9fb112b 100644 --- a/psycopg/psycopg/types/numeric.py +++ b/psycopg/psycopg/types/numeric.py @@ -371,9 +371,9 @@ class NumericBinaryDumper(Dumper): def dump_decimal_to_numeric_binary(obj: Decimal) -> Union[bytearray, bytes]: sign, digits, exp = obj.as_tuple() - if exp == "n" or exp == "N": # type: ignore[comparison-overlap] + if exp == "n" or exp == "N": return NUMERIC_NAN_BIN - elif exp == "F": # type: ignore[comparison-overlap] + elif exp == "F": return NUMERIC_NINF_BIN if sign else NUMERIC_PINF_BIN # Weights of py digits into a pg digit according to their positions. diff --git a/psycopg/setup.py b/psycopg/setup.py index b07339fca..6af918aa0 100644 --- a/psycopg/setup.py +++ b/psycopg/setup.py @@ -38,7 +38,7 @@ extras_require = { # Requirements to run the test suite "test": [ "anyio >= 3.6.2", - "mypy >= 0.990", + "mypy >= 1.0", "pproxy >= 2.7", "pytest >= 6.2.5", "pytest-cov >= 3.0", diff --git a/tests/constraints.txt b/tests/constraints.txt index d4b9ffc06..0e19f20b5 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 == 0.990 +mypy == 1.0.0 pproxy == 2.7.0 pytest == 6.2.5 pytest-cov == 3.0.0 diff --git a/tests/test_copy.py b/tests/test_copy.py index 17cf2fc78..3a26f7863 100644 --- a/tests/test_copy.py +++ b/tests/test_copy.py @@ -320,7 +320,7 @@ def test_subclass_adapter(conn, format): if format == Format.TEXT: from psycopg.types.string import StrDumper as BaseDumper else: - from psycopg.types.string import ( # type: ignore[no-redef] + from psycopg.types.string import ( # type: ignore[assignment] StrBinaryDumper as BaseDumper, ) diff --git a/tests/test_copy_async.py b/tests/test_copy_async.py index 79e97c0c6..e49d8ff65 100644 --- a/tests/test_copy_async.py +++ b/tests/test_copy_async.py @@ -312,7 +312,7 @@ async def test_subclass_adapter(aconn, format): if format == Format.TEXT: from psycopg.types.string import StrDumper as BaseDumper else: - from psycopg.types.string import ( # type: ignore[no-redef] + from psycopg.types.string import ( # type: ignore[assignment] StrBinaryDumper as BaseDumper, ) diff --git a/tests/test_server_cursor.py b/tests/test_server_cursor.py index f7b6c8ed6..385dcd774 100644 --- a/tests/test_server_cursor.py +++ b/tests/test_server_cursor.py @@ -17,7 +17,7 @@ def test_init_row_factory(conn): with psycopg.ServerCursor(conn, "bar") as cur: assert cur.name == "bar" - assert cur.row_factory is rows.dict_row # type: ignore + assert cur.row_factory is rows.dict_row with psycopg.ServerCursor(conn, "baz", row_factory=rows.namedtuple_row) as cur: assert cur.name == "baz" diff --git a/tests/test_server_cursor_async.py b/tests/test_server_cursor_async.py index 8325639c1..99ff9cc76 100644 --- a/tests/test_server_cursor_async.py +++ b/tests/test_server_cursor_async.py @@ -19,7 +19,7 @@ async def test_init_row_factory(aconn): async with psycopg.AsyncServerCursor(aconn, "bar") as cur: assert cur.name == "bar" - assert cur.row_factory is rows.dict_row # type: ignore + assert cur.row_factory is rows.dict_row async with psycopg.AsyncServerCursor( aconn, "baz", row_factory=rows.namedtuple_row