-
Notifications
You must be signed in to change notification settings - Fork 765
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
SQLAlchemy Session __enter__ and __exit__ methods not being noticed. #2088
Comments
Yes, your diagnosis is correct. The bundled stubs don't include |
I'll also note that the latest published version of sqlalchemy-stubs also doesn't include these methods. Perhaps it was a recent addition to the library? |
Maintaining compatibility between a library and the corresponding stubs presents a challenge for the Python ecosystem. Our preference and recommendation is that library maintainers include type information (in the form of inlined types or type stubs) as part of their library package. This is the best way to prevent incompatibilities like this. Thankfully, we're seeing that many libraries are now directly incorporating type information! It helps if consumers of a library express their desire for type information to be included. If this is something you'd like to see for sqlalchemy, perhaps you'd be willing to file an enhancement request in the sqlalchemy repo? |
https://github.com/sqlalchemy/sqlalchemy/blame/958f902b1fc528fed0be550bc573545de47ed854/lib/sqlalchemy/orm/session.py#L1131 says it was added 17 months ago. |
I think pylance currently bundles the stubs from Longer term, the best answer is for sqlalchemy to ship type information as part of their package. |
Have opened dropbox/sqlalchemy-stubs#231 |
Triage: I think we should close this:
|
Environment data
Expected behaviour
We have a session builder being used, and a method new_session:
All places in the code where we call this method should be error free:
Actual behaviour
All places in the code where we call this method
gets red squiggly lines under the
rdb.new_session()
Following the Session definition through, the
__enter__
and__exit__
methods are clearly there.Logs
Python Language Server Log
I'm guessing that the stubs being bundled don't specify the enter and exit methods.
The text was updated successfully, but these errors were encountered: