-
-
Notifications
You must be signed in to change notification settings - Fork 685
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
AsyncSession does not play well with typing and autocompletion #54
Comments
Do the type hints work with the vanilla SQLAlchemy |
@MrAwesomeRocks, I don't think they work, no. However, I expect them to work with the given code snippet since SQLModel positions itself as an IDE friendly SQLAlchemy wrapper. The |
@obassett, acknowledged! Well, I'm happy to help anyway :) |
The samples uses a "create_async_engine" directly from SQLAlchemy but uses the AsynSession from SQLmodel. Is this the way to go? |
I'm not sure if it's the way, but it's certainly a way :) Are there any other ways to use it you aware of? |
There is any workaround to have the right type check? |
@lucasteles just check the attached PR. For now, you can manually patch (or ignore) AsyncSession.exec typing for the |
Any updates? |
@tiangolo, fix this, please. |
Thanks all for the conversation! And thanks @Bobronium for the PR with the fix! 🙇 This will be available in the next version, |
TL;DR: Fix is available here: #58, pls merge.
First Check
Commit to Help
Example Code
Description
First of all, props for yet another amazing library! 🎉❤️
I didn't dive into source code yet to verify that I'm doing the right thing, but in the runtime the snippet behaves as expected. However that's not the case with static analysis:
Mypy gives this error:
PyCharm fails to derive
session
variable type:May be related to PY-29891!
Even when
session
type explicitly stated, PyCharm still struggles to provide same experience as with syncSession
I acknowledge that the issue might be caused Typing/MyPy/PyCharm limitations.
I would be happy to work towards fixing the issue in my free time. Ideally, for that I'd want some clarification and thoughts regarding the issue.
Operating System
macOS 11.4 (20F71)
SQLModel Version
0.0.4
Python Version
Python 3.9.6
Additional Context
pip install aiosqlite sqlalchemy[asyncio]
0.910
PyCharm 2021.1.3 (Professional Edition) Build #PY-211.7628.24, built on June 30, 2021
The text was updated successfully, but these errors were encountered: