Skip to content

Commit 0c6e99e

Browse files
chore: implement type vars
1 parent 1fdffa1 commit 0c6e99e

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

web3/module.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
Coroutine,
66
Dict,
77
Optional,
8-
Sequence,
98
Tuple,
109
TypeVar,
1110
Union,
12-
cast,
11+
overload,
1312
)
1413

1514
from eth_abi.codec import (
@@ -27,13 +26,14 @@
2726
)
2827
from web3.method import (
2928
Method,
29+
RequestArgs,
30+
ResponseFormatters,
3031
)
3132
from web3.providers.persistent import (
3233
PersistentConnectionProvider,
3334
)
3435
from web3.types import (
3536
FormattedEthSubscriptionResponse,
36-
RPCEndpoint,
3737
RPCResponse,
3838
)
3939

@@ -58,34 +58,50 @@ def apply_result_formatters(
5858
TReturn = TypeVar("TReturn")
5959

6060

61+
@overload
62+
def retrieve_request_information_for_batching(
63+
w3: "AsyncWeb3",
64+
module: "Module",
65+
method: Method[Callable[..., Any]],
66+
) -> Callable[..., Coroutine[Any, Any, Tuple[RequestArgs, ResponseFormatters]]]:
67+
...
68+
69+
@overload
70+
def retrieve_request_information_for_batching(
71+
w3: "Web3",
72+
module: "Module",
73+
method: Method[Callable[..., Any]],
74+
) -> Callable[..., Tuple[RequestArgs, ResponseFormatters]]:
75+
...
76+
6177
@curry
6278
def retrieve_request_information_for_batching(
6379
w3: Union["AsyncWeb3", "Web3"],
6480
module: "Module",
6581
method: Method[Callable[..., Any]],
6682
) -> Union[
67-
Callable[..., Tuple[Tuple[RPCEndpoint, Any], Sequence[Any]]],
68-
Callable[..., Coroutine[Any, Any, Tuple[Tuple[RPCEndpoint, Any], Sequence[Any]]]],
83+
Callable[..., Tuple[RequestArgs, ResponseFormatters]],
84+
Callable[..., Coroutine[Any, Any, Tuple[RequestArgs, ResponseFormatters]]],
6985
]:
7086
async def async_inner(
7187
*args: Any, **kwargs: Any
72-
) -> Tuple[Tuple[RPCEndpoint, Any], Sequence[Any]]:
88+
) -> Tuple[RequestArgs, ResponseFormatters]:
7389
(method_str, params), response_formatters = method.process_params(
7490
module, *args, **kwargs
7591
)
7692
if isinstance(w3.provider, PersistentConnectionProvider):
7793
w3.provider._request_processor.cache_request_information(
78-
None, cast(RPCEndpoint, method_str), params, response_formatters
94+
None, method_str, params, response_formatters
7995
)
80-
return (cast(RPCEndpoint, method_str), params), response_formatters
96+
return (method_str, params), response_formatters
8197

8298
def inner(
8399
*args: Any, **kwargs: Any
84-
) -> Tuple[Tuple[RPCEndpoint, Any], Sequence[Any]]:
100+
) -> Tuple[RequestArgs, ResponseFormatters]:
85101
(method_str, params), response_formatters = method.process_params(
86102
module, *args, **kwargs
87103
)
88-
return (cast(RPCEndpoint, method_str), params), response_formatters
104+
return (method_str, params), response_formatters
89105

90106
return async_inner if module.is_async else inner
91107

@@ -142,7 +158,7 @@ async def caller(
142158

143159
if isinstance(async_w3.provider, PersistentConnectionProvider):
144160
return await async_w3.manager.socket_request(
145-
cast(RPCEndpoint, method_str),
161+
method_str,
146162
params,
147163
response_formatters=response_formatters,
148164
)

0 commit comments

Comments
 (0)