]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Make `Mapped` covariant
authorRomeoDespres <Romeo.Despres@warnermusic.com>
Tue, 29 Aug 2023 10:11:11 +0000 (06:11 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 30 Aug 2023 14:57:08 +0000 (10:57 -0400)
commit2ec9b21fa744947319bfc49b6bdddc165487844a
tree5c2a0755f8c33fec70b43379664805d56f6ab7fe
parentd18ccdc997185b74e1506072805dcb71fde5fe07
Make `Mapped` covariant

Made the contained type for :class:`.Mapped` covariant; this is to allow
greater flexibility for end-user typing scenarios, such as the use of
protocols to represent particular mapped class structures that are passed
to other functions. As part of this change, the contained type was also
made covariant for dependent and related types such as
:class:`_orm.base.SQLORMOperations`, :class:`_orm.WriteOnlyMapped`, and
:class:`_sql.SQLColumnExpression`. Pull request courtesy Roméo Després.

within the change, there is a bit of adjustment to ``__radd__()`` to
match the typing of ``__add__()``, which previously was slightly
different for some reason and not passing on mypy with this change.

Fixes: #10288
Closes: #10289
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10289
Pull-request-sha: 50eee7021cd29d59f52d8ff10c69d2970e1c1534

Change-Id: Ic55723a78b0b3b47dfff927d9ee0b94301272a6a
doc/build/changelog/unreleased_20/10288.rst [new file with mode: 0644]
lib/sqlalchemy/ext/hybrid.py
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/roles.py
test/typing/plain_files/orm/mapped_covariant.py [new file with mode: 0644]