diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13b11e6a..fc7358a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,19 @@ repos: - id: isort # profile and line-length to avoid clashes with black args: ["--profile=black", "--line-length=88"] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.8.0 + hooks: + - id: mypy + pass_filenames: false + args: + - --install-types + - --non-interactive + - --follow-imports=silent + - --ignore-missing-imports + - --implicit-optional + - --package + - boa default_language_version: python: python3.10 diff --git a/Makefile b/Makefile index f8835335..1235e12e 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ all: lint build lint: pre-commit run --all-files - mypy --install-types --non-interactive --follow-imports=silent --ignore-missing-imports --implicit-optional -p boa build: pip install . diff --git a/boa/contracts/vyper/vyper_contract.py b/boa/contracts/vyper/vyper_contract.py index 5faa9f82..5ef18264 100644 --- a/boa/contracts/vyper/vyper_contract.py +++ b/boa/contracts/vyper/vyper_contract.py @@ -446,14 +446,14 @@ def __repr__(self): class VyperContract(_BaseVyperContract): def __init__( self, - compiler_data, + compiler_data: CompilerData, *args, - env=None, - override_address=None, + env: Env = None, + override_address: Address = None, # whether to skip constructor skip_initcode=False, - created_from=None, - filename=None, + created_from: Address = None, + filename: str = None, ): super().__init__(compiler_data, env, filename) @@ -475,7 +475,7 @@ def __init__( addr = Address(override_address) else: addr = self._run_init(*args, override_address=override_address) - self._address: Address = addr + self._address = addr for fn_name, fn in external_fns.items(): setattr(self, fn_name, VyperFunction(fn, self)) diff --git a/boa/environment.py b/boa/environment.py index c544e76c..230168e1 100644 --- a/boa/environment.py +++ b/boa/environment.py @@ -6,7 +6,7 @@ import random import sys import warnings -from typing import Any, Iterator, Optional, Tuple +from typing import Any, Iterator, Optional, Tuple, TypeAlias import eth.constants as constants import eth.tools.builder.chain as chain @@ -96,7 +96,7 @@ def anchor(self): # make mypy happy -_AddressType = Address | str | bytes | PYEVM_Address +_AddressType: TypeAlias = Address | str | bytes | PYEVM_Address _opcode_overrides = {} diff --git a/boa/network.py b/boa/network.py index f9e60f1c..ddcbc2e8 100644 --- a/boa/network.py +++ b/boa/network.py @@ -4,7 +4,6 @@ from dataclasses import dataclass from functools import cached_property from math import ceil -from typing import Any from eth_account import Account from requests.exceptions import HTTPError @@ -189,9 +188,9 @@ def get_eip1559_fee(self) -> tuple[str, str, str, str]: max_fee = to_hex(base_fee_estimate + to_int(max_priority_fee)) return to_hex(base_fee_estimate), max_priority_fee, max_fee, chain_id - def get_static_fee(self) -> list[Any]: + def get_static_fee(self) -> tuple[str, str]: # non eip-1559 transaction - return self._rpc.fetch_multi([("eth_gasPrice", []), ("eth_chainId", [])]) + return tuple(self._rpc.fetch_multi([("eth_gasPrice", []), ("eth_chainId", [])])) def _check_sender(self, address): if address is None: diff --git a/boa/rpc.py b/boa/rpc.py index c52da6fc..749f95b2 100644 --- a/boa/rpc.py +++ b/boa/rpc.py @@ -47,9 +47,9 @@ def to_bytes(hex_str: str) -> bytes: class RPCError(Exception): - def __init__(self, message, code): + def __init__(self, message: str, code: int): super().__init__(f"{code}: {message}") - self.code: str = code + self.code = code @classmethod def from_json(cls, data):