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

Little problem with the type hint #1205

Closed
Zoupers opened this issue May 6, 2023 · 4 comments
Closed

Little problem with the type hint #1205

Zoupers opened this issue May 6, 2023 · 4 comments

Comments

@Zoupers
Copy link
Contributor

Zoupers commented May 6, 2023

image
sqlalchemy does not exporse orm as a clear attr, so the type hint there is not working.
now we change that to this with full path.
image
And it works out with the type hint.

The main problem with that might be the use of some thing like db.session, which I use a lot in project to do CRUD operations. Previously we have that. It will stock since sa don't have orm attr. It's a module.

) -> sa.orm.scoped_session[Session]:

And I think we should make this little change to provide more type hint info.

Environment:

  • Python version: 3.9.16
  • Flask-SQLAlchemy version: 3.0.3
  • SQLAlchemy version: 2.0.0 and above
@Zoupers Zoupers mentioned this issue May 6, 2023
6 tasks
@davidism
Copy link
Member

davidism commented May 6, 2023

It's a bug with pyright: microsoft/pyright#3884. I'm willing to take the suggested fix of import sqlalchemy.orm as sa_orm.

@Zoupers
Copy link
Contributor Author

Zoupers commented May 6, 2023

It't not only sa.orm, but also sa.exc and sa.event. But they can adopt the rule to be like sa_exc and sa_event. OK?

@davidism
Copy link
Member

davidism commented May 6, 2023

Yes, that's what I meant.

@pamelafox
Copy link
Contributor

Fixed in 3.0.4 which is now released. Thanks for the PR!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants