|
7 | 7 | import json |
8 | 8 | import urllib.parse |
9 | 9 | from dataclasses import dataclass |
10 | | -from typing import Any, TypeAlias |
| 10 | +from typing import Any |
11 | 11 |
|
12 | 12 | from dune_client.types import QueryParameter |
13 | 13 |
|
14 | | -QueryParameterValue: TypeAlias = str | list[str] |
15 | | -SerializedParameterValue: TypeAlias = QueryParameterValue | int |
16 | | -QueryParameterPayload: TypeAlias = dict[str, QueryParameterValue] |
17 | | -SerializedParameters: TypeAlias = dict[str, SerializedParameterValue] |
18 | | -RequestPayload: TypeAlias = dict[str, str | QueryParameterPayload] |
19 | | - |
20 | 14 |
|
21 | 15 | def parse_query_object_or_id( |
22 | 16 | query: QueryBase | str | int, |
23 | | -) -> tuple[SerializedParameters | None, int]: |
| 17 | +) -> tuple[dict[str, str | list[str] | int] | None, int]: |
24 | 18 | """ |
25 | 19 | Users are allowed to pass QueryBase or ID into some functions. |
26 | 20 | This method handles both scenarios, returning a pair of the form (params, query_id) |
27 | 21 | """ |
28 | 22 | if isinstance(query, QueryBase): |
29 | | - params: SerializedParameters = { |
| 23 | + params: dict[str, str | list[str] | int] = { |
30 | 24 | f"params.{p.key}": p.to_dict()["value"] for p in query.parameters() |
31 | 25 | } |
32 | 26 | return params, query.query_id |
@@ -73,7 +67,7 @@ def __hash__(self) -> int: |
73 | 67 | """ |
74 | 68 | return self.url().__hash__() |
75 | 69 |
|
76 | | - def request_format(self) -> RequestPayload: |
| 70 | + def request_format(self) -> dict[str, str | dict[str, str | list[str]]]: |
77 | 71 | """Transforms Query objects to params to pass in API""" |
78 | 72 | return {"query_parameters": {p.key: p.to_dict()["value"] for p in self.parameters()}} |
79 | 73 |
|
|
0 commit comments