Skip to content

Commit 4215632

Browse files
authored
Fix/warnings (#2239)
* fix: warnings - closes #1009 * fix: lint errors on main * fix: del unused param
1 parent a853489 commit 4215632

File tree

8 files changed

+28
-37
lines changed

8 files changed

+28
-37
lines changed

src/ethereum_clis/transition_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ def _evaluate_stream(
479479
output.result.traces = self.collect_traces(
480480
output.result.receipts, temp_dir, debug_output_path
481481
)
482-
temp_dir.cleanup()
483482

483+
temp_dir.cleanup()
484484
return output
485485

486486
def safe_t8n_args(

src/ethereum_test_specs/blockchain.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any, Callable, ClassVar, Dict, Generator, List, Sequence, Tuple, Type
55

66
import pytest
7-
from pydantic import ConfigDict, Field, field_validator
7+
from pydantic import ConfigDict, Field, field_validator, model_serializer
88

99
from ethereum_clis import BlockExceptionWithMessage, Result, TransitionTool
1010
from ethereum_test_base_types import (
@@ -141,15 +141,14 @@ class Header(CamelModel):
141141
engine_api_error_code=EngineAPIError.InvalidParams, ) ```
142142
"""
143143

144-
model_config = ConfigDict(
145-
arbitrary_types_allowed=True,
146-
# explicitly set Removable items to None so they are not included in
147-
# the serialization (in combination with exclude_None=True in
148-
# model.dump()).
149-
json_encoders={
150-
Removable: lambda x: None,
151-
},
152-
)
144+
model_config = ConfigDict(arbitrary_types_allowed=True)
145+
146+
@model_serializer(mode="wrap", when_used="json")
147+
def _serialize_model(self, serializer, info):
148+
"""Exclude Removable fields from serialization."""
149+
del info
150+
data = serializer(self)
151+
return {k: v for k, v in data.items() if not isinstance(v, Removable)}
153152

154153
@field_validator("withdrawals_root", mode="before")
155154
@classmethod

src/ethereum_test_specs/static_state/account.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Any, Dict, List, Mapping, Set, Tuple
44

5-
from pydantic import BaseModel
5+
from pydantic import BaseModel, ConfigDict
66

77
from ethereum_test_base_types import Bytes, EthereumTestRootModel, HexNumber, Storage
88
from ethereum_test_types import Alloc
@@ -54,11 +54,7 @@ class AccountInFiller(BaseModel, TagDependentData):
5454
nonce: ValueInFiller | None = None
5555
storage: StorageInPre | None = None
5656

57-
class Config:
58-
"""Model Config."""
59-
60-
extra = "forbid"
61-
arbitrary_types_allowed = True # For CodeInFiller
57+
model_config = ConfigDict(arbitrary_types_allowed=True, extra="forbid")
6258

6359
def tag_dependencies(self) -> Mapping[str, Tag]:
6460
"""Get tag dependencies."""

src/ethereum_test_specs/static_state/environment.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Any, Dict
44

5-
from pydantic import BaseModel, Field, model_validator
5+
from pydantic import BaseModel, ConfigDict, Field, model_validator
66

77
from ethereum_test_base_types import Address
88
from ethereum_test_types import Environment
@@ -26,10 +26,7 @@ class EnvironmentInStateTestFiller(BaseModel):
2626

2727
current_excess_blob_gas: ValueInFiller | None = Field(None, alias="currentExcessBlobGas")
2828

29-
class Config:
30-
"""Model Config."""
31-
32-
extra = "forbid"
29+
model_config = ConfigDict(extra="forbid")
3330

3431
@model_validator(mode="after")
3532
def check_fields(self) -> "EnvironmentInStateTestFiller":

src/ethereum_test_specs/static_state/general_transaction.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Any, Dict, Generator, List, Mapping
44

5-
from pydantic import BaseModel, Field, field_validator, model_validator
5+
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
66

77
from ethereum_test_base_types import Address, CamelModel, EthereumTestRootModel, Hash
88
from ethereum_test_exceptions import TransactionExceptionInstanceOrList
@@ -127,10 +127,7 @@ class GeneralTransactionInFiller(BaseModel, TagDependentData):
127127
max_fee_per_blob_gas: ValueInFiller | None = Field(None, alias="maxFeePerBlobGas")
128128
blob_versioned_hashes: List[Hash] | None = Field(None, alias="blobVersionedHashes")
129129

130-
class Config:
131-
"""Model Config."""
132-
133-
extra = "forbid"
130+
model_config = ConfigDict(extra="forbid")
134131

135132
def tag_dependencies(self) -> Mapping[str, Tag]:
136133
"""Get tag dependencies."""

src/ethereum_test_specs/static_state/state_static.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66
from _pytest.mark.structures import ParameterSet
7-
from pydantic import BaseModel, Field, model_validator
7+
from pydantic import BaseModel, ConfigDict, Field, model_validator
88

99
from ethereum_test_forks import Fork
1010
from ethereum_test_types import Alloc
@@ -37,10 +37,7 @@ class StateStaticTest(BaseStaticTest):
3737
transaction: GeneralTransactionInFiller
3838
expect: List[ExpectSectionInStateTestFiller]
3939

40-
class Config:
41-
"""Model Config."""
42-
43-
extra = "forbid"
40+
model_config = ConfigDict(extra="forbid")
4441

4542
def model_post_init(self, context):
4643
"""Initialize StateStaticTest."""

src/pytest_plugins/eels_resolver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@ def pytest_configure(config: pytest.Config) -> None:
6161
config._eels_resolutions_file = eels_resolutions_file # type: ignore
6262

6363

64-
def pytest_report_header(config: pytest.Config, startdir: Path) -> str:
64+
def pytest_report_header(config: pytest.Config, start_path: Path) -> str:
6565
"""
6666
Report the EELS_RESOLUTIONS_FILE path to the pytest report header.
6767
6868
Args:
6969
config (pytest.Config): The pytest configuration object.
70-
startdir (Path): The starting directory for the test run.
70+
start_path (Path): The starting directory for the test run.
7171
7272
Returns:
7373
str: A string to add to the pytest report header.
7474
7575
"""
76-
del startdir
76+
del start_path
7777

7878
eels_resolutions_file = getattr(config, "_eels_resolutions_file", None)
7979
if eels_resolutions_file:

tests/homestead/identity_precompile/test_identity.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def test_identity_return_overwrite(
2020
pre: Alloc,
2121
call_opcode: Op,
2222
):
23-
"""Test the return data of the identity precompile overwriting its input."""
23+
"""
24+
Test the return data of the identity precompile overwriting its input.
25+
"""
2426
code = (
2527
sum(Op.MSTORE8(offset=i, value=(i + 1)) for i in range(4)) # memory = [1, 2, 3, 4]
2628
+ call_opcode(
@@ -62,7 +64,10 @@ def test_identity_return_buffer_modify(
6264
pre: Alloc,
6365
call_opcode: Op,
6466
):
65-
"""Test the modification of the input range to attempt to modify the return buffer."""
67+
"""
68+
Test the modification of the input range to attempt to modify the return
69+
buffer.
70+
"""
6671
env = Environment()
6772
code = (
6873
sum(Op.MSTORE8(offset=i, value=(i + 1)) for i in range(4)) # memory = [1, 2, 3, 4]

0 commit comments

Comments
 (0)