edgedb / edgedb-python

The official Python client library for EdgeDB
https://edgedb.com
Apache License 2.0
366 stars 43 forks source link

[Feature Request] Can we have template for code generation? #463

Open triumph1 opened 9 months ago

triumph1 commented 9 months ago

Hi! thanks for making the great database! I'm happily learning edgedb nowdays. 😆

can we have template for code generation?

example

below edgeql generates below python code

select 1;
# AUTOGENERATED FROM 'app/queries/test.edgeql' WITH:
#     $ edgedb-py

from __future__ import annotations
import edgedb

async def test(
    executor: edgedb.AsyncIOExecutor,
) -> int:
    return await executor.query_single(
        """\
        select 1;\
        """,
    )

but this code doesn't pass strict mypy check since query_single is returning Any.

cast?

I want to use typing.cast() to pass mypy check

return cast(int, await executor.query_single(
        """\
        select 1;\
        """,
    ))

how do I achieve this? 🤔