fix: refactor tests for mypy
This commit is contained in:
parent
26aa190b03
commit
99f6f3437f
@ -13,7 +13,7 @@ class CallResult(CamelModel):
|
|||||||
gas_used: int
|
gas_used: int
|
||||||
|
|
||||||
@validator("gas_used", pre=True)
|
@validator("gas_used", pre=True)
|
||||||
def maybe_hex_to_int(v):
|
def maybe_hex_to_int(cls, v):
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
return hex_to_int(v)
|
return hex_to_int(v)
|
||||||
return v
|
return v
|
||||||
@ -27,7 +27,7 @@ class CallAction(Web3Model):
|
|||||||
gas: int
|
gas: int
|
||||||
|
|
||||||
@validator("value", "gas", pre=True)
|
@validator("value", "gas", pre=True)
|
||||||
def maybe_hex_to_int(v):
|
def maybe_hex_to_int(cls, v):
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
return hex_to_int(v)
|
return hex_to_int(v)
|
||||||
return v
|
return v
|
||||||
|
@ -24,7 +24,7 @@ class Receipt(CamelModel):
|
|||||||
"cumulative_gas_used",
|
"cumulative_gas_used",
|
||||||
pre=True,
|
pre=True,
|
||||||
)
|
)
|
||||||
def maybe_hex_to_int(v):
|
def maybe_hex_to_int(cls, v):
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
return hex_to_int(v)
|
return hex_to_int(v)
|
||||||
return v
|
return v
|
||||||
|
@ -2,8 +2,6 @@ import json
|
|||||||
import os
|
import os
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
from pydantic import parse_file_as
|
|
||||||
|
|
||||||
from mev_inspect.schemas.blocks import Block
|
from mev_inspect.schemas.blocks import Block
|
||||||
from mev_inspect.schemas.sandwiches import Sandwich
|
from mev_inspect.schemas.sandwiches import Sandwich
|
||||||
|
|
||||||
@ -14,7 +12,10 @@ TEST_SANDWICHES_DIRECTORY = os.path.join(THIS_FILE_DIRECTORY, "sandwiches")
|
|||||||
|
|
||||||
def load_test_sandwiches(block_number: int) -> List[Sandwich]:
|
def load_test_sandwiches(block_number: int) -> List[Sandwich]:
|
||||||
sandwiches_path = f"{TEST_SANDWICHES_DIRECTORY}/{block_number}.json"
|
sandwiches_path = f"{TEST_SANDWICHES_DIRECTORY}/{block_number}.json"
|
||||||
return parse_file_as(List[Sandwich], sandwiches_path)
|
|
||||||
|
with open(sandwiches_path, "r") as file:
|
||||||
|
sandwiches_data = json.load(file)
|
||||||
|
return [Sandwich(**sandwich) for sandwich in sandwiches_data]
|
||||||
|
|
||||||
|
|
||||||
def load_test_block(block_number: int) -> Block:
|
def load_test_block(block_number: int) -> Block:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user