]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add type annotations for postgresql.array()
authorDenis Laxalde <denis@laxalde.org>
Fri, 28 Feb 2025 12:01:54 +0000 (13:01 +0100)
committerDenis Laxalde <denis@laxalde.org>
Thu, 13 Mar 2025 19:53:47 +0000 (20:53 +0100)
commitda5e2c2512c00ae10bea6b1ccb39d0ccf0e7e475
tree6ecd32e05b800783b60eb3c8838d99397c115fc0
parent69714303c761ba574dbe9f34f2bd05ddc544abd4
Add type annotations for postgresql.array()

The type argument of array is inferred from the 'clauses' argument of
the constructor; hence array([1, 2]) has type array[int]. We explicitly
define the 'type_' parameter of __init__() as it helps type inference
when using this argument, e.g. array([], type_=CHAR) is inferred as
array[str]. Consistency between 'clauses' and 'type_' is also ensured.
lib/sqlalchemy/dialects/postgresql/array.py
lib/sqlalchemy/dialects/postgresql/json.py
test/typing/plain_files/dialects/postgresql/pg_stuff.py