-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Description
Problem
PyLance throws type errors when the Dune client is obtained by using the from_env
constructor because the type returned is BaseDuneClient
, which doesn't contain the methods available in QueryAPI
:
- Cannot access attribute "get_query" for class "BaseDuneClient" DuneQueryRepo#11
- Cannot access attribute "update_query" for class "BaseDuneClient" DuneQueryRepo#12
- Cannot access attribute "upload_csv" for class "BaseDuneClient" DuneQueryRepo#9
- Cannot access attribute "run_sql" for class "BaseDuneClient" DuneQueryRepo#8
Solution
I'm not a Python expert but I think that the solution is to override from_env
in the DuneClient
class so that it returns the type like this:
def from_env(cls) -> DuneClient:
Workaround
In the meantime, the workaround is to use the typing
package like so:
dune = cast(DuneClient, DuneClient.from_env())
bh2smith
Metadata
Metadata
Assignees
Labels
No labels