Skip to content

Commit 7dcb52b

Browse files
committed
refactor: convert string-based Enum classes to StrEnum
Replace Enum classes with string values with Python 3.11+ StrEnum for better type safety, cleaner string conversion, and more explicit string enumeration semantics in test configuration and execution contexts.
1 parent 5711b12 commit 7dcb52b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/ethereum_test_specs/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Helper functions."""
22

33
from dataclasses import dataclass
4-
from enum import Enum
4+
from enum import StrEnum
55
from typing import Any, Dict, List
66

77
from ethereum_clis import Result
@@ -15,7 +15,7 @@
1515
from ethereum_test_types import Transaction, TransactionReceipt
1616

1717

18-
class ExecutionContext(Enum):
18+
class ExecutionContext(StrEnum):
1919
"""The execution context in which a test case can fail."""
2020

2121
BLOCK = "Block"

src/ethereum_test_tools/utility/generators.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test generator decorators."""
22

33
import json
4-
from enum import Enum
4+
from enum import StrEnum
55
from pathlib import Path
66
from typing import Dict, Generator, List, Protocol
77

@@ -17,15 +17,15 @@
1717
from ethereum_test_vm import Opcodes as Op
1818

1919

20-
class DeploymentTestType(Enum):
20+
class DeploymentTestType(StrEnum):
2121
"""Represents the type of deployment test."""
2222

2323
DEPLOY_BEFORE_FORK = "deploy_before_fork"
2424
DEPLOY_ON_FORK_BLOCK = "deploy_on_fork_block"
2525
DEPLOY_AFTER_FORK = "deploy_after_fork"
2626

2727

28-
class SystemContractTestType(Enum):
28+
class SystemContractTestType(StrEnum):
2929
"""Represents the type of system contract test."""
3030

3131
GAS_LIMIT = "system_contract_reaches_gas_limit"
@@ -42,7 +42,7 @@ def param(self):
4242
)
4343

4444

45-
class ContractAddressHasBalance(Enum):
45+
class ContractAddressHasBalance(StrEnum):
4646
"""Represents whether the target deployment test has a balance before deployment."""
4747

4848
ZERO_BALANCE = "zero_balance"

0 commit comments

Comments
 (0)