From 2fdfb5527ee0fe55d094f474951db7997b7b5422 Mon Sep 17 00:00:00 2001 From: Bryan Forbes Date: Tue, 15 Nov 2022 09:03:24 -0500 Subject: [PATCH] Fix relationship.order_by typing Fixes: #8776 ### Checklist This pull request is: - [ ] A documentation / typographical error fix - Good to go, no issue or tests are needed - [x] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #` in the commit message - please include tests. Closes: #8779 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8779 Pull-request-sha: 2bc64555a1ab662881fdfd1caaabd9d21fbdf531 Change-Id: I52fe6db5ba954a6039836b45f0e89ad96049df03 --- doc/build/changelog/unreleased_20/8776.rst | 7 +++++++ lib/sqlalchemy/orm/relationships.py | 1 + 2 files changed, 8 insertions(+) create mode 100644 doc/build/changelog/unreleased_20/8776.rst 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]]] -- 2.47.3