Skip to content

Commit 50ec089

Browse files
committed
chore: ignore type error reported by mypy 1.12, 1.13
If a generator returns None, the StopIteration.args tuple is empty. The fact we explicitly checks for it and in that case we return none looks now an error for Mypy. I don't see an obvious way around it. Maybe related to python/mypy#1933 which is an historical issue (opened in 2016). Reported in python/mypy#18073
1 parent 34f76c0 commit 50ec089

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎psycopg/psycopg/waiting.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def wait_selector(gen: PQGen[RV], fileno: int, interval: float | None = None) ->
6464
sel.register(fileno, s)
6565

6666
except StopIteration as ex:
67-
rv: RV = ex.args[0] if ex.args else None
67+
# https://github.com/python/mypy/issues/18073
68+
rv: RV = ex.args[0] if ex.args else None # type: ignore[assignment]
6869
return rv
6970

7071

@@ -99,7 +100,7 @@ def wait_conn(gen: PQGenConn[RV], interval: float | None = None) -> RV:
99100
sel.register(fileno, s)
100101

101102
except StopIteration as ex:
102-
rv: RV = ex.args[0] if ex.args else None
103+
rv: RV = ex.args[0] if ex.args else None # type: ignore[assignment]
103104
return rv
104105

105106

@@ -160,7 +161,7 @@ def wakeup(state: Ready) -> None:
160161
# Assume the connection was closed
161162
raise e.OperationalError(str(ex))
162163
except StopIteration as ex:
163-
rv: RV = ex.args[0] if ex.args else None
164+
rv: RV = ex.args[0] if ex.args else None # type: ignore[assignment]
164165
return rv
165166

166167

@@ -218,7 +219,7 @@ def wakeup(state: Ready) -> None:
218219
fileno, s = gen.send(ready)
219220

220221
except StopIteration as ex:
221-
rv: RV = ex.args[0] if ex.args else None
222+
rv: RV = ex.args[0] if ex.args else None # type: ignore[assignment]
222223
return rv
223224

224225

@@ -255,7 +256,7 @@ def wait_select(gen: PQGen[RV], fileno: int, interval: float | None = None) -> R
255256
s = gen.send(ready)
256257

257258
except StopIteration as ex:
258-
rv: RV = ex.args[0] if ex.args else None
259+
rv: RV = ex.args[0] if ex.args else None # type: ignore[assignment]
259260
return rv
260261

261262

@@ -311,7 +312,7 @@ def wait_epoll(gen: PQGen[RV], fileno: int, interval: float | None = None) -> RV
311312
epoll.modify(fileno, evmask)
312313

313314
except StopIteration as ex:
314-
rv: RV = ex.args[0] if ex.args else None
315+
rv: RV = ex.args[0] if ex.args else None # type: ignore[assignment]
315316
return rv
316317

317318

@@ -359,7 +360,7 @@ def wait_poll(gen: PQGen[RV], fileno: int, interval: float | None = None) -> RV:
359360
poll.modify(fileno, evmask)
360361

361362
except StopIteration as ex:
362-
rv: RV = ex.args[0] if ex.args else None
363+
rv: RV = ex.args[0] if ex.args else None # type: ignore[assignment]
363364
return rv
364365

365366

0 commit comments

Comments
 (0)