]> git.ipfire.org Git - thirdparty/psycopg.git/commit
Make Connection generic on Row
authorDenis Laxalde <denis.laxalde@dalibo.com>
Tue, 20 Apr 2021 08:30:03 +0000 (10:30 +0200)
committerDenis Laxalde <denis.laxalde@dalibo.com>
Wed, 28 Apr 2021 13:08:48 +0000 (15:08 +0200)
commit9e4a835449ae40d9ae9b08cfd3584262ccf576ea
tree31448dbd2599338fbad4a51e76110cb929e83f89
parent412af3419bb19d1615a66dc5e159a9c5393b715d
Make Connection generic on Row

We use a type variable 'RowConn' for Connection that is distinct from
'Row' that is used on Cursor side in order to reflect the possibility to
have distinct row factories on connection and cursor sides.

In order to avoid "propagation" of the Row type variable of Connection
classes, we use Any everywhere that variable is not used (namely,
everywhere outside the connection module).

The typing_example.py almost works: connect(row_factory=...) returns a
typed Connection, but only connect() still returns a Connection[Any].
13 files changed:
psycopg3/psycopg3/_transform.py
psycopg3/psycopg3/_typeinfo.py
psycopg3/psycopg3/adapt.py
psycopg3/psycopg3/connection.py
psycopg3/psycopg3/copy.py
psycopg3/psycopg3/cursor.py
psycopg3/psycopg3/pool/async_pool.py
psycopg3/psycopg3/pool/pool.py
psycopg3/psycopg3/proto.py
psycopg3/psycopg3/server_cursor.py
psycopg3/psycopg3/transaction.py
psycopg3_c/psycopg3_c/_psycopg3.pyi
tests/typing_example.py