]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
typing updates to accept with_polymorphic(), aliases
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 13 Jan 2026 14:19:14 +0000 (09:19 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 13 Jan 2026 16:26:16 +0000 (11:26 -0500)
commit64b3068178b8406caee011d58ecfef75626ea5ea
tree99ca0e079b3da3998db6491e97401d60794d587e
parent1a9d80ab4769951b1153276a026bd610010941df
typing updates to accept with_polymorphic(), aliases

Fixed typing issues where ORM mapped classes and aliased entities could not
be used as keys in result row mappings or as join targets in select
statements. Patterns such as ``row._mapping[User]``,
``row._mapping[aliased(User)]``, ``row._mapping[with_polymorphic(...)]``
(rejected by both mypy and Pylance), and ``.join(aliased(User))``
(rejected by Pylance) are documented and fully supported at runtime but
were previously rejected by type checkers. The type definitions for
:class:`._KeyType` and :class:`._FromClauseArgument` have been updated to
accept these ORM entity types.

Fixes: #13075
Change-Id: Icc3b1ef832b01fd205b1409b2f6d0f211395d4ad
(cherry picked from commit 48410f83407661e009326d7170ab79e5163eb8f1)
doc/build/changelog/unreleased_20/13075.rst [new file with mode: 0644]
lib/sqlalchemy/engine/result.py
lib/sqlalchemy/sql/_typing.py
test/typing/plain_files/engine/engine_result.py
test/typing/plain_files/orm/orm_querying.py
test/typing/plain_files/orm/polymorphic.py [new file with mode: 0644]