edgedb-python icon indicating copy to clipboard operation
edgedb-python copied to clipboard

mypy no longer likes gel_client.get() and .query()

Open anbuzin opened this issue 5 months ago • 6 comments

This code:

user = await gel_client.get(default.User, None)

causes these typing errors:

app/api/router.py:48: error: Function does not return a value (it only ever returns None)  [func-returns-value]
app/api/router.py:48: error: Argument 1 to "get" of "AsyncIOReadOnlyExecutor" has incompatible type "type[User]"; expected "QueryableObject[None] | type[QueryableType[None]]"  [arg-type]

on the latest master (688968c948a7610396669c93cab98ea635081554)

anbuzin avatar Jul 16 '25 12:07 anbuzin

For .query() it turns into:

projects = await gel_client.query(default.Project)
app/api/router.py:72: error: Need type annotation for "projects" (hint: "projects: list[<type>] = ...")  [var-annotated]
app/api/router.py:72: error: Argument 1 to "query" of "AsyncIOReadOnlyExecutor" has incompatible type "type[Project]"; expected "QueryableObject[Never] | type[QueryableType[Never]]"  [arg-type]

anbuzin avatar Jul 16 '25 12:07 anbuzin

There are tests for this in CI (which are passing), so this must be coming from your venv. Are you installing gel-python in editable mode?

elprans avatar Jul 16 '25 14:07 elprans

@elprans normal mode via uv:

uv add "gel @ git+https://github.com/geldata/gel-python.git"

anbuzin avatar Jul 16 '25 18:07 anbuzin

I tried fiddling with the venv and the reflections a little bit but it didn't do much.

anbuzin avatar Jul 16 '25 18:07 anbuzin

Can you repro in a new venv?

1st1 avatar Jul 17 '25 08:07 1st1

Can you also try pip install gel==4.0.0b1 (not from GH), but first pip uninstall gel

1st1 avatar Jul 17 '25 08:07 1st1