From: Bryan Forbes Date: Tue, 8 Nov 2022 21:32:02 +0000 (-0600) Subject: Fix relationship.order_by typing X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2bc64555a1ab662881fdfd1caaabd9d21fbdf531;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fix relationship.order_by typing Fixes: #8776 --- diff --git a/doc/build/changelog/unreleased_20/8776.rst b/doc/build/changelog/unreleased_20/8776.rst new file mode 100644 index 0000000000..fa4156eae0 --- /dev/null +++ b/doc/build/changelog/unreleased_20/8776.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: bug, orm + :tickets: 8776 + + Fixed issue where passing a callbale function returning an iterable + of column elements to :paramref:`_orm.relationship.order_by` was + flagged as an error in type checkers. diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index e0922a5380..986093e025 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -164,6 +164,7 @@ _ORMOrderByArgument = Union[ Literal[False], str, _ColumnExpressionArgument[Any], + Callable[[], Iterable[ColumnElement[Any]]], Iterable[Union[str, _ColumnExpressionArgument[Any]]], ] _ORMBackrefArgument = Union[str, Tuple[str, Dict[str, Any]]]