Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"order_by" of "Query" does not return a value (same for limit) #78

Closed
charlax opened this issue Apr 29, 2021 · 3 comments
Closed

"order_by" of "Query" does not return a value (same for limit) #78

charlax opened this issue Apr 29, 2021 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@charlax
Copy link

charlax commented Apr 29, 2021

Describe the bug

total = query.order_by(None).count()
items = query.limit(10).offset(10).all()
mypy --strict test.py
error: "order_by" of "Query" does not return a value
error: "limit" of "Query" does not return a value

Expected behavior

This is a valid usage of Query. The doc states that ORM Query is considered legacy in v2, it is still usable.

To Reproduce

from typing import Any

from sqlalchemy.orm import Query


def paginate(query: Query) -> Any:
    total = query.order_by(None).count()
    items = query.limit(10).offset(10).all()
    return [total, items]

Error

mypy --strict test.py
test.py:7: error: "order_by" of "Query" does not return a value
test.py:8: error: "limit" of "Query" does not return a value
Found 2 errors in 1 file (checked 1 source file)

Versions.

❯ pip list
Package           Version
----------------- -------
greenlet          1.0.0
mypy              0.812
mypy-extensions   0.4.3
pip               21.0.1
setuptools        54.2.0
SQLAlchemy        1.4.11
sqlalchemy2-stubs 0.0.1a4
typed-ast         1.4.3
typing-extensions 3.7.4.3

Have a nice day and thanks for the amazing work!

@charlax charlax added the requires triage New issue that requires categorization label Apr 29, 2021
@MaicoTimmerman
Copy link
Contributor

The stubs are being updated frequently and I believe this has been fixed in #70. Can you try install the master branch of the stubs?

@MaicoTimmerman MaicoTimmerman added bug Something isn't working duplicate This issue or pull request already exists and removed requires triage New issue that requires categorization labels Apr 29, 2021
@charlax
Copy link
Author

charlax commented Apr 29, 2021

Indeed, works fine with master, thanks!

@charlax charlax closed this as completed Apr 29, 2021
@CaselIT
Copy link
Member

CaselIT commented Apr 29, 2021

We will try to release an update shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants