Skip to content

Commit caafc47

Browse files
chore: fix mypy errors [no-untyped-def] (#638)
* chore: fix mypy errors [no-untyped-def] * chore: `mypyc` for python3.8 * chore: `black .` * chore: `mypyc` for python3.9 * chore: `mypyc` for python3.10 * chore: `mypyc` for python3.11 * chore: `mypyc` for python3.12 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 0e0f92e commit caafc47

File tree

15 files changed

+19836
-19822
lines changed

15 files changed

+19836
-19822
lines changed

build/ops.txt

+19,797-19,797
Large diffs are not rendered by default.

dank_mids/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
patch_eth_utils()
1919

2020

21-
def _configure_concurrent_future_work_queue_size():
21+
def _configure_concurrent_future_work_queue_size() -> None:
2222
"""
2323
Configures the concurrent futures process pool to allow for a larger number of queued calls.
2424

dank_mids/_batch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(
5454
controller: "DankMiddlewareController",
5555
multicalls: Multicalls,
5656
rpc_calls: JSONRPCBatch,
57-
):
57+
) -> None:
5858
self.controller = controller
5959
"""The controller managing this batch."""
6060

@@ -64,7 +64,7 @@ def __init__(
6464
self.rpc_calls = rpc_calls
6565
"""A list of individual RPC calls or multicalls."""
6666

67-
def __repr__(self):
67+
def __repr__(self) -> str:
6868
return f"<dank_mids.DankBatch object at {hex(id(self))}>"
6969

7070
def __await__(self) -> Generator[Any, None, None]:

dank_mids/_debugging/_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class _FileHelper(metaclass=abc.ABCMeta):
2020
path = f"{os.path.expanduser('~')}/.dank_mids/debug"
2121

22-
def __init__(self, chainid: int):
22+
def __init__(self, chainid: int) -> None:
2323
if not isinstance(chainid, int):
2424
raise TypeError(f"`chainid` must be an integer. You passed {chainid}") from None
2525

dank_mids/_debugging/failures.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class FailedRequestWriter(_CSVWriter):
2727
column_names = "request_type", "request_uid", "request_length", "error", "request_data"
2828
"""The names of the columns in the CSV file."""
2929

30-
def __init__(self, chainid: int, failure_type: Type[BaseException]):
30+
def __init__(self, chainid: int, failure_type: Type[BaseException]) -> None:
3131
"""
3232
Initialize the FailedRequestWriter.
3333
@@ -65,7 +65,7 @@ async def _record_failure(
6565
request_uid: Union[str, int],
6666
request_length: Union[int, Literal["unknown"]],
6767
request_data: Union[List["Request"], List["PartialRequest"], bytes],
68-
):
68+
) -> None:
6969
"""
7070
Record a failed request to the CSV file.
7171

dank_mids/_mode.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from a_sync.functools import cached_property_unsafe as cached_property
22

3+
from typing_extensions import Self
4+
5+
36
MODES = "default", "application", "infura"
47

58

@@ -38,7 +41,7 @@ def infura(self):
3841
return self.mode == "infura"
3942

4043
@property
41-
def mode(self):
44+
def mode(self) -> Self:
4245
"""
4346
Retrieves the current operation mode.
4447

dank_mids/_requests.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def __init__(
226226
method: RPCEndpoint,
227227
params: Any,
228228
uid: Optional[str] = None,
229-
): # sourcery skip: hoist-statement-from-if
229+
) -> None: # sourcery skip: hoist-statement-from-if
230230
_request_base_init(self, controller, uid)
231231
if method[-4:] == "_raw":
232232
self.method = method[:-4]
@@ -534,7 +534,7 @@ def __set_exception(self, data: Exception) -> None:
534534
self.__log_set_exception(error_logger_log_debug, data)
535535
self._fut.set_exception(data)
536536

537-
def __log_set_exception(self, log_func: Callable[..., None], exc: Exception):
537+
def __log_set_exception(self, log_func: Callable[..., None], exc: Exception) -> None:
538538
exc_type = type(exc).__name__
539539
log_func("%s for %s", exc_type, self)
540540
log_func("exception set: %s", repr(exc))
@@ -636,7 +636,7 @@ class _Batch(_RequestBase[List[_Response]], Iterable[_Request]):
636636

637637
__slots__ = "calls", "_batcher", "_lock", "_done", "_daemon", "__dict__"
638638

639-
def __init__(self, controller: "DankMiddlewareController", calls: Iterable[_Request]):
639+
def __init__(self, controller: "DankMiddlewareController", calls: Iterable[_Request]) -> None:
640640
_request_base_init(self, controller)
641641
self.calls = WeakList(calls)
642642
self._batcher = controller.batcher
@@ -746,7 +746,7 @@ def __init__(
746746
controller: "DankMiddlewareController",
747747
calls: Iterable[eth_call] = [],
748748
bid: Optional[BatchId] = None,
749-
):
749+
) -> None:
750750
# sourcery skip: default-mutable-arg
751751
_batch_init(self, controller, calls)
752752
self.bid = bid or self.controller.multicall_uid.next

dank_mids/_web3/abi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ def get_mapper(
7070
class IteratorProxy(Iterable[TValue]):
7171
"""Wraps an iterator to return when iterated upon"""
7272

73-
def __init__(self, iterator: Iterator[TValue]):
73+
def __init__(self, iterator: Iterator[TValue]) -> None:
7474
self.__wrapped = iterator
7575

76-
def __iter__(self):
76+
def __iter__(self) -> Iterator[TValue]:
7777
try:
7878
return self.__dict__.pop("_IteratorProxy__wrapped")
7979
except KeyError as e:

dank_mids/_web3/method.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def bypass_get_code_formatter(eth: Type[BaseEth]) -> None:
204204
)
205205

206206

207-
def bypass_formatters(eth):
207+
def bypass_formatters(eth) -> None:
208208
"""Executes a sequence of bypass methods to remove default formatters for ETH methods.
209209
210210
Utilizes a predefined list of bypass methods to systematically modify the corresponding

dank_mids/brownie_patch/_abi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class FunctionABI:
1313
for each unique set of ABI parameters, optimizing memory usage and performance.
1414
"""
1515

16-
def __init__(self, **abi: Any):
16+
def __init__(self, **abi: Any) -> None:
1717
"""
1818
Initialize a FunctionABI instance with the given ABI information.
1919

dank_mids/brownie_patch/_method.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
from decimal import Decimal
2-
from typing import Any, Awaitable, Callable, Dict, Generic, Iterable, List, Optional, TypeVar
2+
from typing import (
3+
Any,
4+
Awaitable,
5+
Callable,
6+
Dict,
7+
Generator,
8+
Generic,
9+
Iterable,
10+
List,
11+
Optional,
12+
TypeVar,
13+
)
314

415
from a_sync import igather
516
from brownie.convert.datatypes import EthAddress
@@ -27,7 +38,7 @@ class _DankMethodMixin(Generic[_EVMType]):
2738

2839
_prep_request_data: Callable[..., Awaitable[BytesLike]]
2940

30-
def __init__(self):
41+
def __init__(self) -> None:
3142
self._len_inputs = len(self.abi["inputs"])
3243

3344
# cache `_call` on this object to prevent repeated imports due to circ import
@@ -44,7 +55,7 @@ def __init__(self):
4455

4556
self._skip_decoder_proc_pool = self._address in call._skip_proc_pool
4657

47-
def __await__(self):
58+
def __await__(self) -> Generator[Any, None, _EVMType]:
4859
"""
4960
Allow the contract method to be awaited.
5061

dank_mids/brownie_patch/contract.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def from_explorer(
152152
signatures: Dict[Method, Signature]
153153
"""A dictionary mapping method names to their corresponding signatures."""
154154

155-
def __init__(self, *args, **kwargs):
155+
def __init__(self, *args, **kwargs) -> None:
156156
"""
157157
Initialize the Contract instance.
158158
@@ -241,7 +241,7 @@ def __get_method_object__(self, name: str) -> DankContractMethod:
241241
return overloaded # type: ignore [return-value]
242242

243243

244-
def _is_function_abi(abi: dict):
244+
def _is_function_abi(abi: dict) -> bool:
245245
return abi["type"] == "function"
246246

247247

dank_mids/helpers/_errors.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def revert_logger_log_debug(msg: str, *args) -> None:
4343
}
4444

4545

46-
def log_internal_error(logger: Logger, batch: "_Batch", exc: Exception):
46+
def log_internal_error(logger: Logger, batch: "_Batch", exc: Exception) -> None:
4747
try:
4848
batch_objs = list(batch)
4949
except TypeError:
@@ -68,7 +68,7 @@ def format_error_response(request: PartialRequest, error: Error) -> RPCError:
6868
return response
6969

7070

71-
def needs_full_request_spec(response: PartialResponse):
71+
def needs_full_request_spec(response: PartialResponse) -> bool:
7272
"""
7373
Determine if a response indicates that the node requires the full request specification.
7474
@@ -97,7 +97,7 @@ def is_call_revert(e: BadResponse) -> bool:
9797
return any(map(f"{e}".lower().__contains__, INDIVIDUAL_CALL_REVERT_STRINGS))
9898

9999

100-
def log_request_type_switch():
100+
def log_request_type_switch() -> None:
101101
error_logger_debug(
102102
"your node says the partial request was invalid but its okay, we can use the full jsonrpc spec instead"
103103
)

dank_mids/semaphores.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class BlockSemaphore(_AbstractPrioritySemaphore):
6262
_top_priority: Literal[-1]
6363
"""The highest priority value, set to -1."""
6464

65-
def __init__(self, value=1, *, name=None):
65+
def __init__(self, value=1, *, name=None) -> None:
6666
super().__init__(_BlockSemaphoreContextManager, -1, int(value), name=name)
6767

6868
def __getitem__(self, block: Union[int, HexStr, Literal["latest", None]]) -> "_BlockSemaphoreContextManager": # type: ignore [override]

dank_mids/stats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def _log_list_types(self, values, level: _LogLevel = DEVHINT) -> None:
340340
class _Collector:
341341
"""Handles the collection and computation of stats-related data."""
342342

343-
def __init__(self):
343+
def __init__(self) -> None:
344344
self.errd_batches: Deque["JSONRPCBatch"] = deque(maxlen=500)
345345
"""
346346
A deque that stores information about failed JSON-RPC batches.

0 commit comments

Comments
 (0)