Skip to content

Commit f7740da

Browse files
committed
chore: upgrade mypy to 0.981
Most changes needed by python/typeshed#8446.
1 parent 4f5c03e commit f7740da

6 files changed

Lines changed: 21 additions & 24 deletions

File tree

psycopg/psycopg/pq/_pq_ctypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def type2str(fname, narg, t):
758758
"LP_c_ulong",
759759
"LP_FILE",
760760
):
761-
return f"pointer[{t.__name__[3:]}]"
761+
return f"_Pointer[{t.__name__[3:]}]"
762762

763763
else:
764764
assert False, f"can't deal with {t} in {fname}"

psycopg/psycopg/pq/_pq_ctypes.pyi

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ types stub for ctypes functions
55
# Copyright (C) 2020 The Psycopg Team
66

77
from typing import Any, Callable, Optional, Sequence
8-
from ctypes import Array, pointer
8+
from ctypes import Array, pointer, _Pointer
99
from ctypes import c_char, c_char_p, c_int, c_ubyte, c_uint, c_ulong
1010

1111
class FILE: ...
1212

13-
def fdopen(fd: int, mode: bytes) -> pointer[FILE]: ... # type: ignore[type-var]
13+
def fdopen(fd: int, mode: bytes) -> _Pointer[FILE]: ... # type: ignore[type-var]
1414

1515
Oid = c_uint
1616

@@ -62,14 +62,14 @@ def PQprepare(
6262
) -> PGresult_struct: ...
6363
def PQgetvalue(
6464
arg1: Optional[PGresult_struct], arg2: int, arg3: int
65-
) -> pointer[c_char]: ...
65+
) -> _Pointer[c_char]: ...
6666
def PQcmdTuples(arg1: Optional[PGresult_struct]) -> bytes: ...
6767
def PQescapeStringConn(
6868
arg1: Optional[PGconn_struct],
6969
arg2: c_char_p,
7070
arg3: bytes,
7171
arg4: int,
72-
arg5: pointer[c_int],
72+
arg5: _Pointer[c_int],
7373
) -> int: ...
7474
def PQescapeString(arg1: c_char_p, arg2: bytes, arg3: int) -> int: ...
7575
def PQsendPrepare(
@@ -98,10 +98,10 @@ def PQsetNoticeReceiver(
9898
# a subtype of "ctypes._CData"
9999
def PQnotifies(
100100
arg1: Optional[PGconn_struct],
101-
) -> Optional[pointer[PGnotify_struct]]: ... # type: ignore
101+
) -> Optional[_Pointer[PGnotify_struct]]: ... # type: ignore
102102
def PQputCopyEnd(arg1: Optional[PGconn_struct], arg2: Optional[bytes]) -> int: ...
103103

104-
# Arg 2 is a pointer, reported as _CArgObject by mypy
104+
# Arg 2 is a _Pointer, reported as _CArgObject by mypy
105105
def PQgetCopyData(arg1: Optional[PGconn_struct], arg2: Any, arg3: int) -> int: ...
106106
def PQsetResultAttrs(
107107
arg1: Optional[PGresult_struct],
@@ -110,7 +110,7 @@ def PQsetResultAttrs(
110110
) -> int: ...
111111
def PQtrace(
112112
arg1: Optional[PGconn_struct],
113-
arg2: pointer[FILE], # type: ignore[type-var]
113+
arg2: _Pointer[FILE], # type: ignore[type-var]
114114
) -> None: ...
115115
def PQencryptPasswordConn(
116116
arg1: Optional[PGconn_struct],
@@ -133,7 +133,7 @@ def PQconnectPoll(arg1: Optional[PGconn_struct]) -> int: ...
133133
def PQconndefaults() -> Sequence[PQconninfoOption_struct]: ...
134134
def PQconninfoFree(arg1: Sequence[PQconninfoOption_struct]) -> None: ...
135135
def PQconninfo(arg1: Optional[PGconn_struct]) -> Sequence[PQconninfoOption_struct]: ...
136-
def PQconninfoParse(arg1: bytes, arg2: pointer[c_char_p]) -> Sequence[PQconninfoOption_struct]: ...
136+
def PQconninfoParse(arg1: bytes, arg2: _Pointer[c_char_p]) -> Sequence[PQconninfoOption_struct]: ...
137137
def PQfinish(arg1: Optional[PGconn_struct]) -> None: ...
138138
def PQreset(arg1: Optional[PGconn_struct]) -> None: ...
139139
def PQresetStart(arg1: Optional[PGconn_struct]) -> int: ...
@@ -158,7 +158,7 @@ def PQconnectionNeedsPassword(arg1: Optional[PGconn_struct]) -> int: ...
158158
def PQconnectionUsedPassword(arg1: Optional[PGconn_struct]) -> int: ...
159159
def PQsslInUse(arg1: Optional[PGconn_struct]) -> int: ...
160160
def PQexec(arg1: Optional[PGconn_struct], arg2: bytes) -> PGresult_struct: ...
161-
def PQexecParams(arg1: Optional[PGconn_struct], arg2: bytes, arg3: int, arg4: pointer[c_uint], arg5: pointer[c_char_p], arg6: pointer[c_int], arg7: pointer[c_int], arg8: int) -> PGresult_struct: ...
161+
def PQexecParams(arg1: Optional[PGconn_struct], arg2: bytes, arg3: int, arg4: _Pointer[c_uint], arg5: _Pointer[c_char_p], arg6: _Pointer[c_int], arg7: _Pointer[c_int], arg8: int) -> PGresult_struct: ...
162162
def PQdescribePrepared(arg1: Optional[PGconn_struct], arg2: bytes) -> PGresult_struct: ...
163163
def PQdescribePortal(arg1: Optional[PGconn_struct], arg2: bytes) -> PGresult_struct: ...
164164
def PQresultStatus(arg1: Optional[PGresult_struct]) -> int: ...
@@ -182,11 +182,11 @@ def PQcmdStatus(arg1: Optional[PGresult_struct]) -> Optional[bytes]: ...
182182
def PQoidValue(arg1: Optional[PGresult_struct]) -> int: ...
183183
def PQescapeLiteral(arg1: Optional[PGconn_struct], arg2: bytes, arg3: int) -> Optional[bytes]: ...
184184
def PQescapeIdentifier(arg1: Optional[PGconn_struct], arg2: bytes, arg3: int) -> Optional[bytes]: ...
185-
def PQescapeByteaConn(arg1: Optional[PGconn_struct], arg2: bytes, arg3: int, arg4: pointer[c_ulong]) -> pointer[c_ubyte]: ...
186-
def PQescapeBytea(arg1: bytes, arg2: int, arg3: pointer[c_ulong]) -> pointer[c_ubyte]: ...
187-
def PQunescapeBytea(arg1: bytes, arg2: pointer[c_ulong]) -> pointer[c_ubyte]: ...
185+
def PQescapeByteaConn(arg1: Optional[PGconn_struct], arg2: bytes, arg3: int, arg4: _Pointer[c_ulong]) -> _Pointer[c_ubyte]: ...
186+
def PQescapeBytea(arg1: bytes, arg2: int, arg3: _Pointer[c_ulong]) -> _Pointer[c_ubyte]: ...
187+
def PQunescapeBytea(arg1: bytes, arg2: _Pointer[c_ulong]) -> _Pointer[c_ubyte]: ...
188188
def PQsendQuery(arg1: Optional[PGconn_struct], arg2: bytes) -> int: ...
189-
def PQsendQueryParams(arg1: Optional[PGconn_struct], arg2: bytes, arg3: int, arg4: pointer[c_uint], arg5: pointer[c_char_p], arg6: pointer[c_int], arg7: pointer[c_int], arg8: int) -> int: ...
189+
def PQsendQueryParams(arg1: Optional[PGconn_struct], arg2: bytes, arg3: int, arg4: _Pointer[c_uint], arg5: _Pointer[c_char_p], arg6: _Pointer[c_int], arg7: _Pointer[c_int], arg8: int) -> int: ...
190190
def PQsendDescribePrepared(arg1: Optional[PGconn_struct], arg2: bytes) -> int: ...
191191
def PQsendDescribePortal(arg1: Optional[PGconn_struct], arg2: bytes) -> int: ...
192192
def PQgetResult(arg1: Optional[PGconn_struct]) -> PGresult_struct: ...

psycopg/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
],
3838
# Requirements to run the test suite
3939
"test": [
40-
"mypy >= 0.940",
40+
"mypy >= 0.981",
4141
"pproxy >= 2.7",
4242
"pytest >= 6.2.5",
4343
"pytest-asyncio >= 0.17",
@@ -49,7 +49,7 @@
4949
"black >= 22.3.0",
5050
"dnspython >= 2.1",
5151
"flake8 >= 4.0",
52-
"mypy >= 0.940",
52+
"mypy >= 0.981",
5353
"types-setuptools >= 57.4",
5454
"wheel >= 0.37",
5555
],

tests/constraints.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ backports.zoneinfo == 0.2.0
88
typing-extensions == 4.1.0
99

1010
# From the 'test' extra
11-
mypy == 0.940
11+
mypy == 0.981
1212
pproxy == 2.7.0
1313
pytest == 6.2.5
1414
pytest-asyncio == 0.17.0
@@ -19,7 +19,7 @@ pytest-randomly == 3.10.0
1919
black == 22.3.0
2020
dnspython == 2.1.0
2121
flake8 == 4.0.0
22-
mypy == 0.940
22+
mypy == 0.981
2323
types-setuptools == 57.4.0
2424
wheel == 0.37
2525

tests/test_adapt.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,7 @@ def test_optimised_adapters():
407407

408408
# All the registered adapters
409409
reg_adapters = set()
410-
adapters = (
411-
list(postgres.adapters._dumpers.values())
412-
+ postgres.adapters._loaders # type: ignore[operator]
413-
)
410+
adapters = list(postgres.adapters._dumpers.values()) + postgres.adapters._loaders
414411
assert len(adapters) == 5
415412
for m in adapters:
416413
reg_adapters |= set(m.values())

tests/test_psycopg_dbapi20.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def connect(self):
4040

4141

4242
# Shut up warnings
43-
PsycopgTests.failUnless = PsycopgTests.assertTrue # type: ignore[assignment]
44-
PsycopgTPCTests.assertEquals = PsycopgTPCTests.assertEqual # type: ignore[assignment]
43+
PsycopgTests.failUnless = PsycopgTests.assertTrue
44+
PsycopgTPCTests.assertEquals = PsycopgTPCTests.assertEqual
4545

4646

4747
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)