From: Daniele Varrazzo Date: Tue, 8 Jun 2021 12:58:59 +0000 (+0100) Subject: Better naming and typing for a couple of vars X-Git-Tag: 3.0.dev0~35 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=03e892313bdb593114e30b7de18b5a0ae422dc22;p=thirdparty%2Fpsycopg.git Better naming and typing for a couple of vars Note that mypy has some issue there, so a "type: ignore" that seems required cannot be actually added. --- diff --git a/psycopg3/psycopg3/waiting.py b/psycopg3/psycopg3/waiting.py index 3db9954db..f4a779cfe 100644 --- a/psycopg3/psycopg3/waiting.py +++ b/psycopg3/psycopg3/waiting.py @@ -53,11 +53,13 @@ def wait_selector( sel = DefaultSelector() while 1: sel.register(fileno, s) - ready = None - while not ready: - ready = sel.select(timeout=timeout) + rlist = None + while not rlist: + rlist = sel.select(timeout=timeout) sel.unregister(fileno) - s = gen.send(ready[0][1]) + # note: this line should require a cast, but mypy doesn't complain + ready: Ready = rlist[0][1] + s = gen.send(ready) except StopIteration as ex: rv: RV = ex.args[0] if ex.args else None @@ -84,11 +86,12 @@ def wait_conn(gen: PQGenConn[RV], timeout: Optional[float] = None) -> RV: sel = DefaultSelector() while 1: sel.register(fileno, s) - ready = sel.select(timeout=timeout) + rlist = sel.select(timeout=timeout) sel.unregister(fileno) - if not ready: + if not rlist: raise e.OperationalError("timeout expired") - fileno, s = gen.send(ready[0][1]) # type: ignore[arg-type] + ready: Ready = rlist[0][1] # type: ignore[assignment] + fileno, s = gen.send(ready) except StopIteration as ex: rv: RV = ex.args[0] if ex.args else None