piccolo icon indicating copy to clipboard operation
piccolo copied to clipboard

Feature Request: typehints (autocompletes) for query result

Open Bobronium opened this issue 3 years ago • 2 comments

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 https://github.com/tiangolo/sqlmodel/pull/58: image

Bobronium avatar Jul 15 '22 11:07 Bobronium

@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 avatar Jul 15 '22 11:07 dantownsend

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.

dantownsend avatar Jul 15 '22 15:07 dantownsend