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

🔧 fix(type annotation): Add SelectOfScalar to AsyncSession exec statement type annotation #584

Conversation

AlexShein
Copy link

Hi, the statement argument type annotation of the exec method in the AsyncSession doesn't include SelectOfScalar[_T] causing mypy to complain about using await session.exec(select(Model)):

error: Argument 1 to "exec" of "AsyncSession" has incompatible type "SelectOfScalar[Model]"; expected "Union[Select[<nothing>], Executable[<nothing>]]"

Since the synchronous self.sync_session.exec is used under the hood, type annotations for the statement argument should be the same.

@github-actions
Copy link

📝 Docs preview for commit 43b4d4a at: https://6437d39190ee0c0f959f8b51--sqlmodel.netlify.app

@antont
Copy link

antont commented May 12, 2023

Hi, just a question, if you don't mind:

We are using, with SA 1.4, session and select from there directly:

from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.future import select

is there some benefit to using them via SQLModel? I haven't noticed any problems with just using the SA ones directly. The version in SQLModel that this PR touches does not seem to do much?

@tiangolo tiangolo added the bug Something isn't working label Oct 22, 2023
@tiangolo
Copy link
Member

Thank you! This was solved in #58

The fix will be available in the next version, 0.0.9 🎉

Given that I'll close this one, but thanks for the work! ☕

@tiangolo tiangolo closed this Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants