|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from typing_extensions import Any, MutableMapping, TypedDict, Literal |
| 3 | +import typing |
| 4 | + |
| 5 | +if typing.TYPE_CHECKING: |
| 6 | + from typing_extensions import Any, MutableMapping, TypedDict, Literal |
4 | 7 |
|
5 | 8 |
|
6 | 9 | mesc_env_vars = [ |
|
17 | 20 | ] |
18 | 21 |
|
19 | 22 |
|
20 | | -class Endpoint(TypedDict): |
21 | | - name: str |
22 | | - url: str |
23 | | - chain_id: str | None |
24 | | - endpoint_metadata: MutableMapping[str, Any] |
25 | | - |
| 23 | +if typing.TYPE_CHECKING: |
26 | 24 |
|
27 | | -class Profile(TypedDict): |
28 | | - name: str |
29 | | - default_endpoint: str | None |
30 | | - network_defaults: MutableMapping[str, str] |
31 | | - profile_metadata: MutableMapping[str, Any] |
32 | | - use_mesc: bool |
| 25 | + class Endpoint(TypedDict): |
| 26 | + name: str |
| 27 | + url: str |
| 28 | + chain_id: str | None |
| 29 | + endpoint_metadata: MutableMapping[str, Any] |
33 | 30 |
|
| 31 | + class Profile(TypedDict): |
| 32 | + name: str |
| 33 | + default_endpoint: str | None |
| 34 | + network_defaults: MutableMapping[str, str] |
| 35 | + profile_metadata: MutableMapping[str, Any] |
| 36 | + use_mesc: bool |
34 | 37 |
|
35 | | -class RpcConfig(TypedDict): |
36 | | - mesc_version: str |
37 | | - default_endpoint: str | None |
38 | | - endpoints: MutableMapping[str, Endpoint] |
39 | | - network_defaults: MutableMapping[str, str] |
40 | | - network_names: MutableMapping[str, str] |
41 | | - profiles: MutableMapping[str, Profile] |
42 | | - global_metadata: MutableMapping[str, Any] |
| 38 | + class RpcConfig(TypedDict): |
| 39 | + mesc_version: str |
| 40 | + default_endpoint: str | None |
| 41 | + endpoints: MutableMapping[str, Endpoint] |
| 42 | + network_defaults: MutableMapping[str, str] |
| 43 | + network_names: MutableMapping[str, str] |
| 44 | + profiles: MutableMapping[str, Profile] |
| 45 | + global_metadata: MutableMapping[str, Any] |
43 | 46 |
|
44 | 47 |
|
45 | 48 | endpoint_types: dict[str, type | tuple[type, ...]] = { |
@@ -71,61 +74,58 @@ class RpcConfig(TypedDict): |
71 | 74 | # # query types |
72 | 75 | # |
73 | 76 |
|
74 | | - |
75 | | -class EndpointQuery(TypedDict): |
76 | | - query_type: Literal[ |
77 | | - 'default_endpoint', |
78 | | - 'endpoint_by_name', |
79 | | - 'endpoint_by_network', |
80 | | - 'user_input', |
81 | | - ] |
82 | | - fields: ( |
83 | | - DefaultEndpointQuery | EndpointNameQuery | EndpointNetworkQuery | UserInputQuery |
84 | | - ) |
85 | | - |
86 | | - |
87 | | -class DefaultEndpointQuery(TypedDict): |
88 | | - profile: str | None |
89 | | - |
90 | | - |
91 | | -class EndpointNameQuery(TypedDict): |
92 | | - name: str |
93 | | - |
94 | | - |
95 | | -class EndpointNetworkQuery(TypedDict): |
96 | | - profile: str | None |
97 | | - chain_id: str | int |
98 | | - |
99 | | - |
100 | | -class UserInputQuery(TypedDict): |
101 | | - profile: str | None |
102 | | - user_input: str |
103 | | - |
104 | | - |
105 | | -class MultiEndpointQuery(TypedDict, total=False): |
106 | | - name_contains: str | None |
107 | | - url_contains: str | None |
108 | | - chain_id: str | int | None |
109 | | - |
110 | | - |
111 | | -class GlobalMetadataQuery(TypedDict, total=False): |
112 | | - profile: str | None |
113 | | - |
114 | | - |
115 | | -class MescQuery(TypedDict): |
116 | | - query_type: Literal[ |
117 | | - 'default_endpoint', |
118 | | - 'endpoint_by_name', |
119 | | - 'endpoint_by_network', |
120 | | - 'user_input', |
121 | | - 'multi_endpoint', |
122 | | - 'global_metadata', |
123 | | - ] |
124 | | - fields: ( |
125 | | - DefaultEndpointQuery |
126 | | - | EndpointNameQuery |
127 | | - | EndpointNetworkQuery |
128 | | - | UserInputQuery |
129 | | - | MultiEndpointQuery |
130 | | - | GlobalMetadataQuery |
131 | | - ) |
| 77 | +if typing.TYPE_CHECKING: |
| 78 | + |
| 79 | + class EndpointQuery(TypedDict): |
| 80 | + query_type: Literal[ |
| 81 | + 'default_endpoint', |
| 82 | + 'endpoint_by_name', |
| 83 | + 'endpoint_by_network', |
| 84 | + 'user_input', |
| 85 | + ] |
| 86 | + fields: ( |
| 87 | + DefaultEndpointQuery |
| 88 | + | EndpointNameQuery |
| 89 | + | EndpointNetworkQuery |
| 90 | + | UserInputQuery |
| 91 | + ) |
| 92 | + |
| 93 | + class DefaultEndpointQuery(TypedDict): |
| 94 | + profile: str | None |
| 95 | + |
| 96 | + class EndpointNameQuery(TypedDict): |
| 97 | + name: str |
| 98 | + |
| 99 | + class EndpointNetworkQuery(TypedDict): |
| 100 | + profile: str | None |
| 101 | + chain_id: str | int |
| 102 | + |
| 103 | + class UserInputQuery(TypedDict): |
| 104 | + profile: str | None |
| 105 | + user_input: str |
| 106 | + |
| 107 | + class MultiEndpointQuery(TypedDict, total=False): |
| 108 | + name_contains: str | None |
| 109 | + url_contains: str | None |
| 110 | + chain_id: str | int | None |
| 111 | + |
| 112 | + class GlobalMetadataQuery(TypedDict, total=False): |
| 113 | + profile: str | None |
| 114 | + |
| 115 | + class MescQuery(TypedDict): |
| 116 | + query_type: Literal[ |
| 117 | + 'default_endpoint', |
| 118 | + 'endpoint_by_name', |
| 119 | + 'endpoint_by_network', |
| 120 | + 'user_input', |
| 121 | + 'multi_endpoint', |
| 122 | + 'global_metadata', |
| 123 | + ] |
| 124 | + fields: ( |
| 125 | + DefaultEndpointQuery |
| 126 | + | EndpointNameQuery |
| 127 | + | EndpointNetworkQuery |
| 128 | + | UserInputQuery |
| 129 | + | MultiEndpointQuery |
| 130 | + | GlobalMetadataQuery |
| 131 | + ) |
0 commit comments