Skip to content

Commit 267af33

Browse files
committed
type annotations, ug, when did python become Java?
1 parent d1a2d54 commit 267af33

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

p2p/lightchain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ async def get_receipts(self, block_hash: Hash32) -> List[Receipt]:
149149

150150
@alru_cache(maxsize=1024, cache_exceptions=False)
151151
async def get_account(self, block_hash: Hash32, address: Address) -> Account:
152-
return await self._reattempt_on_bad_response(
152+
return await self._retry_on_bad_response(
153153
partial(self._get_account_from_peer, block_hash, address)
154154
)
155155

@@ -192,7 +192,7 @@ async def get_contract_code(self, block_hash: Hash32, address: Address) -> bytes
192192

193193
code_hash = account.code_hash
194194

195-
return await self._reattempt_on_bad_response(
195+
return await self._retry_on_bad_response(
196196
partial(self._get_contract_code_from_peer, block_hash, address, code_hash)
197197
)
198198

@@ -260,7 +260,7 @@ async def _get_proof(self,
260260
reply = await self._wait_for_reply(request_id)
261261
return reply['proof']
262262

263-
async def _reattempt_on_bad_response(self, make_request_to_peer):
263+
async def _retry_on_bad_response(self, make_request_to_peer: Callable[[LESPeer], Any]) -> Any:
264264
for _ in range(MAX_REQUEST_ATTEMPTS):
265265
peer = cast(LESPeer, self.peer_pool.highest_td_peer)
266266
try:

p2p/service.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
Any,
77
Awaitable,
88
Callable,
9-
Dict,
109
List,
1110
Optional,
12-
Tuple,
1311
TypeVar
1412
cast,
1513
)
@@ -132,17 +130,17 @@ async def _cleanup(self) -> None:
132130
raise NotImplementedError()
133131

134132

135-
def service_timeout(timeout):
133+
def service_timeout(timeout: int) -> Callable[..., Any]:
136134
"""
137135
Decorator to time out a method call.
138136
139137
:param timeout: seconds to wait before raising a timeout exception
140138
141139
:raise asyncio.futures.TimeoutError: if the call is not complete before timeout seconds
142140
"""
143-
def decorator(func):
141+
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
144142
@functools.wraps(func)
145-
async def wrapped(service: BaseService, *args: Tuple, **kwargs: Dict) -> Any:
143+
async def wrapped(service: BaseService, *args: Any, **kwargs: Any) -> Any:
146144
return await service.wait(
147145
func(service, *args, **kwargs),
148146
timeout=timeout,

0 commit comments

Comments
 (0)