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

Feature Request: typehints (autocompletes) for query result #561

Closed
Bobronium opened this issue Jul 15, 2022 · 2 comments · Fixed by #562
Closed

Feature Request: typehints (autocompletes) for query result #561

Bobronium opened this issue Jul 15, 2022 · 2 comments · Fixed by #562

Comments

@Bobronium
Copy link

Tab completion support - works great with iPython and VSCode.

While autocompletion does work when building the query, unfortunately, it does not work for query results:

image

I can imagine that it can be nontrivial to implement, but SQLModel proved that it's possible:
Screenshot from fastapi/sqlmodel#58:
image

@dantownsend
Copy link
Member

@Bobronium You're right, there's a few places where tab completion needs improving.

When I originally wrote the library, both iPython and VSCode used the jedi library under the hood for tab completion, and it gave pretty solid results. But now VSCode uses Pylance. And I think Pycharm uses something proprietary.

What I do as a work around is this:

import typing as t

band: t.Optional[Band] = await Band.objects().first()

I have some ideas for how to fix it using Python's TypeVar - need to have a play around!

@dantownsend
Copy link
Member

I had a play around, and managed to get it working using a combination of Generic and TypeVar.

Still needs a bit of work, but at least we know it's possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants