Skip to content

Commit ca35212

Browse files
committed
chore: mypy fixes part 1.
1 parent f80467a commit ca35212

File tree

16 files changed

+39
-39
lines changed

16 files changed

+39
-39
lines changed

src/cli/check_fixtures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from ethereum_test_base_types import to_json
1313
from ethereum_test_fixtures.file import Fixtures
14-
from ethereum_test_specs.base import HashMismatchException
14+
from ethereum_test_specs.base import HashMismatchExceptionError
1515

1616

1717
def count_json_files_exclude_index(start_path: Path) -> int:
@@ -42,13 +42,13 @@ def check_json(json_file_path: Path):
4242
for fixture_name, fixture in fixtures.items():
4343
new_hash = fixtures_deserialized[fixture_name].hash
4444
if (original_hash := fixture.hash) != new_hash:
45-
raise HashMismatchException(
45+
raise HashMismatchExceptionError(
4646
original_hash,
4747
new_hash,
4848
message=f"Fixture hash attributes do not match for {fixture_name}",
4949
)
5050
if "hash" in fixture.info and fixture.info["hash"] != original_hash:
51-
raise HashMismatchException(
51+
raise HashMismatchExceptionError(
5252
original_hash,
5353
fixture.info["hash"],
5454
message=f"Fixture info['hash'] does not match calculated hash for {fixture_name}",

src/cli/eofwrap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def _wrap_fixture(self, fixture: BlockchainFixture, traces: bool):
298298
def _validate_eof(self, container: Container, metrics: bool = True) -> bool:
299299
eof_parse = EOFParse()
300300

301-
result = eof_parse.run(input=to_hex(container))
301+
result = eof_parse.run(input_value=to_hex(container))
302302
actual_message = result.stdout.strip()
303303
if "OK" not in actual_message:
304304
if metrics:

src/ethereum_test_rpc/rpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class BaseRPC:
4545

4646
namespace: ClassVar[str]
4747

48-
def __init__(self, url: str, extra_headers: Dict = None):
48+
def __init__(self, url: str, extra_headers: Dict | None = None):
4949
"""Initialize BaseRPC class with the given url."""
5050
if extra_headers is None:
5151
extra_headers = {}
@@ -60,7 +60,7 @@ def __init_subclass__(cls) -> None:
6060
namespace = namespace[:-3]
6161
cls.namespace = namespace.lower()
6262

63-
def post_request(self, method: str, *params: Any, extra_headers: Dict = None) -> Any:
63+
def post_request(self, method: str, *params: Any, extra_headers: Dict | None = None) -> Any:
6464
"""Send JSON-RPC POST request to the client RPC server at port defined in the url."""
6565
if extra_headers is None:
6666
extra_headers = {}
@@ -101,7 +101,7 @@ class EthRPC(BaseRPC):
101101
BlockNumberType = Union[int, Literal["latest", "earliest", "pending"]]
102102

103103
def __init__(
104-
self, url: str, extra_headers: Dict = None, *, transaction_wait_timeout: int = 60
104+
self, url: str, extra_headers: Dict | None = None, *, transaction_wait_timeout: int = 60
105105
):
106106
"""Initialize EthRPC class with the given url and transaction wait timeout."""
107107
if extra_headers is None:
@@ -257,7 +257,7 @@ class EngineRPC(BaseRPC):
257257
simulators.
258258
"""
259259

260-
def post_request(self, method: str, *params: Any, extra_headers: Dict = None) -> Any:
260+
def post_request(self, method: str, *params: Any, extra_headers: Dict | None = None) -> Any:
261261
"""Send JSON-RPC POST request to the client RPC server at port defined in the url."""
262262
if extra_headers is None:
263263
extra_headers = {}

src/ethereum_test_specs/eof.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def make_eof_test_fixture(
225225
args = []
226226
if vector.container_kind == ContainerKind.INITCODE:
227227
args.append("--initcode")
228-
result = eof_parse.run(*args, input=str(vector.code))
228+
result = eof_parse.run(*args, input_value=str(vector.code))
229229
self.verify_result(result, expected_result, vector.code)
230230

231231
return fixture

src/ethereum_test_specs/tests/test_expect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def test_post_balance_value_mismatch(pre: Alloc, post: Alloc, state_test, t8n, f
224224
(
225225
{ADDRESS_UNDER_TEST: Account(balance=1)},
226226
{ADDRESS_UNDER_TEST: Account(balance=1), Address(0x02): Account(balance=1)},
227-
Alloc.MissingAccount,
227+
Alloc.MissingAccountError,
228228
),
229229
(
230230
{ADDRESS_UNDER_TEST: Account(balance=1)},
@@ -234,7 +234,7 @@ def test_post_balance_value_mismatch(pre: Alloc, post: Alloc, state_test, t8n, f
234234
(
235235
{ADDRESS_UNDER_TEST: Account(balance=1)},
236236
{ADDRESS_UNDER_TEST: Account.NONEXISTENT},
237-
Alloc.UnexpectedAccount,
237+
Alloc.UnexpectedAccountError,
238238
),
239239
],
240240
indirect=["pre", "post"],

src/ethereum_test_tools/code/generators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class Initcode(Bytecode):
4343
def __new__(
4444
cls,
4545
*,
46-
deploy_code: SupportsBytes | Bytes = None,
46+
deploy_code: SupportsBytes | Bytes | None = None,
4747
initcode_length: int | None = None,
48-
initcode_prefix: Bytecode = None,
48+
initcode_prefix: Bytecode | None = None,
4949
initcode_prefix_execution_gas: int = 0,
5050
padding_byte: int = 0x00,
5151
name: str = "",
@@ -195,8 +195,8 @@ def __new__(
195195
cls,
196196
*,
197197
condition: Bytecode | Op,
198-
if_true: Bytecode | Op = None,
199-
if_false: Bytecode | Op = None,
198+
if_true: Bytecode | Op | None = None,
199+
if_false: Bytecode | Op | None = None,
200200
evm_code_type: EVMCodeType = EVMCodeType.LEGACY,
201201
):
202202
"""

src/ethereum_test_types/eof/v1/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def list_header(sections: List["Section"]) -> bytes:
257257

258258
@classmethod
259259
def Code( # noqa: N802
260-
cls, code: BytesConvertible | Bytecode = None, **kwargs
260+
cls, code: Optional[BytesConvertible | Bytecode] = None, **kwargs
261261
) -> "Section":
262262
"""Create new code section with the specified code."""
263263
if code is None:
@@ -435,7 +435,7 @@ def bytecode(self) -> bytes:
435435
return c
436436

437437
@classmethod
438-
def Code(cls, code: BytesConvertible = None, **kwargs) -> "Container": # noqa: N802
438+
def Code(cls, code: Optional[BytesConvertible] = None, **kwargs) -> "Container": # noqa: N802
439439
"""Create simple container with a single code section."""
440440
if code is None:
441441
code = Bytecode()
@@ -446,7 +446,7 @@ def Code(cls, code: BytesConvertible = None, **kwargs) -> "Container": # noqa:
446446
def Init( # noqa: N802
447447
cls,
448448
deploy_container: "Container",
449-
initcode_prefix: Bytecode = None,
449+
initcode_prefix: Optional[Bytecode] = None,
450450
) -> "Container":
451451
"""Create simple init container that deploys the specified container."""
452452
if initcode_prefix is None:

src/ethereum_test_types/tests/test_post_alloc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@ def alloc(request: pytest.FixtureRequest) -> Alloc:
3434
"storage": {0: 1},
3535
}
3636
},
37-
Alloc.UnexpectedAccount,
37+
Alloc.UnexpectedAccountError,
3838
),
3939
# Account should not exist but contained in alloc
4040
(
4141
{"0x00": Account.NONEXISTENT},
4242
{"0x0": {"nonce": "1"}},
43-
Alloc.UnexpectedAccount,
43+
Alloc.UnexpectedAccountError,
4444
),
4545
# Account should not exist but contained in alloc
4646
(
4747
{"0x1": Account.NONEXISTENT},
4848
{"0x01": {"balance": "1"}},
49-
Alloc.UnexpectedAccount,
49+
Alloc.UnexpectedAccountError,
5050
),
5151
# Account should not exist but contained in alloc
5252
(
5353
{"0x0a": Account.NONEXISTENT},
5454
{"0x0A": {"code": "0x00"}},
55-
Alloc.UnexpectedAccount,
55+
Alloc.UnexpectedAccountError,
5656
),
5757
# Account should exist but not in alloc
5858
(
@@ -65,7 +65,7 @@ def alloc(request: pytest.FixtureRequest) -> Alloc:
6565
"storage": {0: 1},
6666
}
6767
},
68-
Alloc.MissingAccount,
68+
Alloc.MissingAccountError,
6969
),
7070
# Account should exist and contained in alloc, but don't care about
7171
# values

src/ethereum_test_types/tests/test_types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,25 +623,25 @@ def test_json_deserialization(
623623
[
624624
pytest.param(
625625
{"gas_price": 1, "max_fee_per_gas": 2},
626-
Transaction.InvalidFeePayment,
626+
Transaction.InvalidFeePaymentError,
627627
"only one type of fee payment field can be used",
628628
id="gas-price-and-max-fee-per-gas",
629629
),
630630
pytest.param(
631631
{"gas_price": 1, "max_priority_fee_per_gas": 2},
632-
Transaction.InvalidFeePayment,
632+
Transaction.InvalidFeePaymentError,
633633
"only one type of fee payment field can be used",
634634
id="gas-price-and-max-priority-fee-per-gas",
635635
),
636636
pytest.param(
637637
{"gas_price": 1, "max_fee_per_blob_gas": 2},
638-
Transaction.InvalidFeePayment,
638+
Transaction.InvalidFeePaymentError,
639639
"only one type of fee payment field can be used",
640640
id="gas-price-and-max-fee-per-blob-gas",
641641
),
642642
pytest.param(
643643
{"ty": 0, "v": 1, "secret_key": 2},
644-
Transaction.InvalidSignaturePrivateKey,
644+
Transaction.InvalidSignaturePrivateKeyError,
645645
"can't define both 'signature' and 'private_key'",
646646
id="type0-signature-and-secret-key",
647647
),

src/ethereum_test_types/types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,21 @@ def verify_post_alloc(self, got_alloc: "Alloc"):
245245
if account is None:
246246
# Account must not exist
247247
if address in got_alloc.root and got_alloc.root[address] is not None:
248-
raise Alloc.UnexpectedAccount(address, got_alloc.root[address])
248+
raise Alloc.UnexpectedAccountError(address, got_alloc.root[address])
249249
else:
250250
if address in got_alloc.root:
251251
got_account = got_alloc.root[address]
252252
assert isinstance(got_account, Account)
253253
assert isinstance(account, Account)
254254
account.check_alloc(address, got_account)
255255
else:
256-
raise Alloc.MissingAccount(address)
256+
raise Alloc.MissingAccountError(address)
257257

258258
def deploy_contract(
259259
self,
260260
code: BytesConvertible,
261261
*,
262-
storage: Storage | StorageRootType = None,
262+
storage: Storage | StorageRootType | None = None,
263263
balance: NumberConvertible = 0,
264264
nonce: NumberConvertible = 1,
265265
address: Address | None = None,

0 commit comments

Comments
 (0)