Are typing errors in fastapi/starlite templates normal ? #709
-
Hi, I'm trying piccolo with the Starlite template and have some typing errors (from pyright/pylance in both vscodium and neovim), for example with the
I get I also get I also get errors when using But maybe that's an editor problem on my side ? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If a primary key isn't manually specified then Piccolo automatically adds To fix this type error, you can add this to your table class: from piccolo.columns.column_types import Serial
class MyTable(Table):
id: Serial
...
Piccolo's To get a list of @get("/tasks", tags=["Task"])
async def tasks() -> t.List[Task]:
tasks = await Task.objects().order_by(Task.id, ascending=False)
return tasks We're working on improving the type annotations for Piccolo - you might need to add something like this for now: @get("/tasks", tags=["Task"])
async def tasks() -> t.List[Task]:
tasks: t.List[Task] = await Task.objects().order_by(Task.id, ascending=False)
return tasks I have quite a large PR underway at the moment which uses Python's generics to improve the type responses of queries, so should help. |
Beta Was this translation helpful? Give feedback.
If a primary key isn't manually specified then Piccolo automatically adds
id
.To fix this type error, you can add this to your table class:
Piccolo's
select
query returns a list of dic…