Skip to content

Commit

Permalink
chore: fixup mypy types (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini authored Feb 14, 2024
1 parent 6fe4fa6 commit 4692160
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions boa/contracts/vyper/ast_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import io
import re
import tokenize
from typing import Any, Optional, Tuple
from typing import Any, Optional

import vyper.ast as vy_ast
from vyper.codegen.core import getpos
Expand Down Expand Up @@ -36,7 +36,7 @@ def _extract_reason(comment: str) -> Any:
# somewhat heuristic.
def reason_at(
source_code: str, lineno: int, end_lineno: int
) -> Optional[Tuple[str, str]]:
) -> Optional[tuple[str, str]]:
block = get_block(source_code, lineno, end_lineno)
c = _get_comment(block)
if c is not None:
Expand Down
6 changes: 3 additions & 3 deletions boa/contracts/vyper/event.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from dataclasses import dataclass
from typing import Any, List
from typing import Any


@dataclass
class Event:
log_id: int # internal py-evm log id, for ordering purposes
address: str # checksum address
event_type: Any # vyper.semantics.types.user.EventT
topics: List[Any] # list of decoded topics
args: List[Any] # list of decoded args
topics: list[Any] # list of decoded topics
args: list[Any] # list of decoded args

def __repr__(self):
t_i = 0
Expand Down
4 changes: 2 additions & 2 deletions boa/contracts/vyper/ir_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ def from_mnemonic(cls, mnemonic):
class OpcodeIRExecutor(IRExecutor):
_type: type = StackItem # type: ignore

def __init__(self, name, opcode_info, *args):
self.opcode_info: OpcodeInfo = opcode_info
def __init__(self, name: str, opcode_info: OpcodeInfo, *args):
self.opcode_info = opcode_info

# to differentiate from implemented codes
self._name = "__" + name + "__"
Expand Down
4 changes: 2 additions & 2 deletions boa/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import random
import sys
import warnings
from typing import Any, Iterator, Optional, Tuple, TypeAlias
from typing import Any, Iterator, Optional, TypeAlias

import eth.constants as constants
import eth.tools.builder.chain as chain
Expand Down Expand Up @@ -593,7 +593,7 @@ def deploy_code(
start_pc: int = 0,
# override the target address:
override_address: Optional[_AddressType] = None,
) -> Tuple[Address, bytes]:
) -> tuple[Address, bytes]:
if gas is None:
gas = self.vm.state.gas_limit

Expand Down
12 changes: 6 additions & 6 deletions boa/test/strategies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import random
import string
from typing import Any, Callable, Iterable, Optional, Tuple, Union
from typing import Any, Callable, Iterable, Optional, Union

from eth_abi.grammar import BasicType, TupleType, parse
from eth_utils import to_checksum_address
Expand All @@ -23,7 +23,7 @@
# note: there are also utils in the vyper codebase we could use for
# this. also, in the future we may want to replace these with strategies
# that use vyper types instead of abi types.
def get_int_bounds(type_str: str) -> Tuple[int, int]:
def get_int_bounds(type_str: str) -> tuple[int, int]:
"""Returns the lower and upper bound for an integer type."""
size = int(type_str.strip("uint") or 256)
if size < 8 or size > 256 or size % 8:
Expand All @@ -43,7 +43,7 @@ def __repr__(self):


def _exclude_filter(fn: Callable) -> Callable:
def wrapper(*args: Tuple, exclude: Any = None, **kwargs: int) -> SearchStrategy:
def wrapper(*args: tuple, exclude: Any = None, **kwargs: int) -> SearchStrategy:
strat = fn(*args, **kwargs)
if exclude is None:
return strat
Expand All @@ -62,7 +62,7 @@ def wrapper(*args: Tuple, exclude: Any = None, **kwargs: int) -> SearchStrategy:

def _check_numeric_bounds(
type_str: str, min_value: NumberType, max_value: NumberType
) -> Tuple:
) -> tuple[NumberType, NumberType]:
lower, upper = get_int_bounds(type_str)
min_final = lower if min_value is None else min_value
max_final = upper if max_value is None else max_value
Expand All @@ -75,8 +75,8 @@ def _check_numeric_bounds(
def _integer_strategy(
type_str: str, min_value: Optional[int] = None, max_value: Optional[int] = None
) -> SearchStrategy:
min_value, max_value = _check_numeric_bounds(type_str, min_value, max_value)
return st.integers(min_value=min_value, max_value=max_value)
min_val, max_val = _check_numeric_bounds(type_str, min_value, max_value)
return st.integers(min_val, max_val)


@_exclude_filter
Expand Down

0 comments on commit 4692160

Please # to comment.