Skip to content

Commit 4741eb2

Browse files
fix linting and typing issue
1 parent 0322c04 commit 4741eb2

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

src/ethereum_test_types/phase_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TestPhaseManager:
2525
Only supports "setup" and "execution" phases now.
2626
"""
2727

28-
def __init__(self, *args, **kwargs):
28+
def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ARG002
2929
"""Initialize TestPhaseManager with empty transactions and blocks."""
3030
self.setup_transactions: List = []
3131
self.setup_blocks: List = []
@@ -53,7 +53,7 @@ def execution(self) -> Iterator["TestPhaseManager"]:
5353
finally:
5454
self._current_phase = old_phase
5555

56-
def add_transaction(self, tx) -> None:
56+
def add_transaction(self, tx: Any) -> None:
5757
"""Add a transaction to the current phase."""
5858
current_phase = self._current_phase
5959
tx.test_phase = current_phase
@@ -63,7 +63,7 @@ def add_transaction(self, tx) -> None:
6363
else:
6464
self.setup_transactions.append(tx)
6565

66-
def add_block(self, block) -> None:
66+
def add_block(self, block: Any) -> None:
6767
"""Add a block to the current phase."""
6868
current_phase = self._current_phase
6969
for tx in block.txs:
@@ -84,7 +84,7 @@ def __get_pydantic_core_schema__(
8484
) -> PlainValidatorFunctionSchema:
8585
"""Pydantic schema for TestPhaseManager."""
8686

87-
def validate_test_phase_manager(value):
87+
def validate_test_phase_manager(value: Any) -> Any:
8888
"""Return the TestPhaseManager instance as-is."""
8989
if isinstance(value, source_type):
9090
return value

src/ethereum_test_types/tests/test_phase_manager.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
from ..phase_manager import TestPhase, TestPhaseManager
99

1010

11-
def test_test_phase_enum_values():
11+
def test_test_phase_enum_values() -> None:
1212
"""Test that TestPhase enum has correct values."""
1313
assert TestPhase.SETUP.value == "setup"
1414
assert TestPhase.EXECUTION.value == "execution"
1515

1616

17-
def test_phase_manager_initialization():
17+
def test_phase_manager_initialization() -> None:
1818
"""Test TestPhaseManager initialization."""
1919
manager = TestPhaseManager()
2020
assert len(manager.setup_transactions) == 0
@@ -24,7 +24,7 @@ def test_phase_manager_initialization():
2424
assert manager.get_current_phase() == TestPhase.EXECUTION
2525

2626

27-
def test_phase_manager_accepts_args_kwargs():
27+
def test_phase_manager_accepts_args_kwargs() -> None:
2828
"""Test that __init__ accepts arbitrary args and kwargs."""
2929
# These should not cause errors
3030
manager1 = TestPhaseManager()
@@ -41,7 +41,7 @@ def test_phase_manager_accepts_args_kwargs():
4141
assert manager.get_current_phase() == TestPhase.EXECUTION
4242

4343

44-
def test_add_transaction_execution_phase():
44+
def test_add_transaction_execution_phase() -> None:
4545
"""Test adding transaction in execution phase."""
4646
manager = TestPhaseManager()
4747
tx = Transaction(to=Address(0x123), value=100, gas_limit=21000)
@@ -54,7 +54,7 @@ def test_add_transaction_execution_phase():
5454
assert len(manager.setup_transactions) == 0
5555

5656

57-
def test_add_transaction_setup_phase():
57+
def test_add_transaction_setup_phase() -> None:
5858
"""Test adding transaction in setup phase."""
5959
manager = TestPhaseManager()
6060
tx = Transaction(to=Address(0x456), value=50, gas_limit=21000)
@@ -68,7 +68,7 @@ def test_add_transaction_setup_phase():
6868
assert len(manager.execution_transactions) == 0
6969

7070

71-
def test_add_block_execution_phase():
71+
def test_add_block_execution_phase() -> None:
7272
"""Test adding block in execution phase."""
7373
manager = TestPhaseManager()
7474
tx1 = Transaction(to=Address(0x111), value=100, gas_limit=21000)
@@ -84,7 +84,7 @@ def test_add_block_execution_phase():
8484
assert len(manager.setup_blocks) == 0
8585

8686

87-
def test_add_block_setup_phase():
87+
def test_add_block_setup_phase() -> None:
8888
"""Test adding block in setup phase."""
8989
manager = TestPhaseManager()
9090
tx1 = Transaction(to=Address(0x333), value=100, gas_limit=21000)
@@ -112,7 +112,9 @@ def test_add_block_setup_phase():
112112
pytest.param(5, 0, 0, 5, id="many_items"),
113113
],
114114
)
115-
def test_mixed_operations(num_setup_txs, num_setup_blocks, num_exec_txs, num_exec_blocks):
115+
def test_mixed_operations(
116+
num_setup_txs: int, num_setup_blocks: int, num_exec_txs: int, num_exec_blocks: int
117+
) -> None:
116118
"""Test mixed operations across phases."""
117119
manager = TestPhaseManager()
118120

@@ -159,7 +161,7 @@ def test_mixed_operations(num_setup_txs, num_setup_blocks, num_exec_txs, num_exe
159161
assert tx.test_phase == TestPhase.EXECUTION.value
160162

161163

162-
def test_empty_block_handling():
164+
def test_empty_block_handling() -> None:
163165
"""Test handling of empty blocks."""
164166
manager = TestPhaseManager()
165167
empty_block = Block(txs=[])
@@ -171,7 +173,7 @@ def test_empty_block_handling():
171173
assert len(manager.setup_blocks[0].txs) == 0
172174

173175

174-
def test_block_with_many_transactions():
176+
def test_block_with_many_transactions() -> None:
175177
"""Test block with many transactions gets all transactions marked."""
176178
manager = TestPhaseManager()
177179

@@ -193,7 +195,7 @@ def test_block_with_many_transactions():
193195
assert tx.test_phase == TestPhase.SETUP.value
194196

195197

196-
def test_phase_switching_preserves_existing_data():
198+
def test_phase_switching_preserves_existing_data() -> None:
197199
"""Test that phase switching doesn't affect existing data."""
198200
manager = TestPhaseManager()
199201

@@ -224,7 +226,7 @@ def test_phase_switching_preserves_existing_data():
224226
assert exec_values == [100, 200, 300]
225227

226228

227-
def test_multiple_managers_phase_isolation():
229+
def test_multiple_managers_phase_isolation() -> None:
228230
"""Test that phase dependence for managers is isolated."""
229231
manager1 = TestPhaseManager()
230232
manager2 = TestPhaseManager()
@@ -268,7 +270,7 @@ def test_multiple_managers_phase_isolation():
268270
pytest.param(TestPhaseManager(), TestPhase.EXECUTION, id="new_instance"),
269271
],
270272
)
271-
def test_manager_properties(manager_instance, expected_phase):
273+
def test_manager_properties(manager_instance: TestPhaseManager, expected_phase: TestPhase) -> None:
272274
"""Test TestPhaseManager instance properties."""
273275
assert isinstance(manager_instance, TestPhaseManager)
274276
assert manager_instance.get_current_phase() == expected_phase

src/pytest_plugins/shared/transaction_fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,6 @@ def typed_transaction(request: pytest.FixtureRequest, fork: Fork) -> Transaction
166166

167167

168168
@pytest.fixture(scope="function")
169-
def test_phase_manager():
169+
def test_phase_manager() -> TestPhaseManager:
170170
"""Fixture providing access to a test phase manager."""
171171
return TestPhaseManager()

0 commit comments

Comments
 (0)