Skip to content

Commit ca37419

Browse files
marioevzLouisTsai-Csiefselmo
authored
refactor(all): Enforce all execution-specs mypy rules (#2281)
* refactor(pyproject): Enforce all execution-specs mypy rules * refactor(base_types): Enforce all execution-specs mypy rules * refactor(types): Enforce all execution-specs mypy rules * refactor(vm): Enforce all execution-specs mypy rules * refactor(forks): Enforce all execution-specs mypy rules * refactor(tests/shanghai): Enforce all execution-specs mypy rules * refactor(fixtures): Enforce all execution-specs mypy rules * refactor(tests/benchmark): Enforce all execution-specs mypy rules * refactor(tests/osaka): Enforce all execution-specs mypy rules refactor(tests/osaka): More fixes * refactor(tests/prague): Enforce all execution-specs mypy rules refactor(tests/prague): More fixes * refactor(tests/cancun): Enforce all execution-specs mypy rules * refactor(tests/homestead): Enforce all execution-specs mypy rules * refactor(tests/frontier): Enforce all execution-specs mypy rules * refactor(tests/istanbul): Enforce all execution-specs mypy rules * refactor(tests/constantinople): Enforce all execution-specs mypy rules * refactor(tests/berlin): Enforce all execution-specs mypy rules * refactor(tests/byzantium): Enforce all execution-specs mypy rules * refactor(tests/paris): Enforce all execution-specs mypy rules * refactor(tests/amsterdam): Enforce all execution-specs mypy rules * refactor(tests/unscheduled): Enforce all execution-specs mypy rules * fix linting issue * refactor(src/ethereum_test_exceptions): Enforce all execution-specs mypy rules * refactor(.github/scripts): Enforce all execution-specs mypy rules * fix typing issue after rebase * refactor(src/ethereum_test_tools): Enforce all execution-specs mypy rules * refactor(src/config): Enforce all execution-specs mypy rules * refactor(src/ethereum_test_checklists): Enforce all execution-specs mypy rules * refactor(src/ethereum_test_rpc): Enforce all execution-specs mypy rules * fix issue after rebase * refactor(specs): Enforce all execution-specs mypy rules * refactor(src/cli,src/ethereum_clis): Enforce all execution-specs mypy rule refactor(clis): More fixes * refactor(src/ethereum_test_execution): Enforce all execution-specs mypy rule * refactor(plugins/forks): Enforce all execution-specs mypy rules refactor(plugins/forks): More fixes * refactor(plugins/logging): Enforce all execution-specs mypy rules * refactor(src/pytest_plugins/solc): Enforce all execution-specs mypy rule refactor(plugins/solc): More fixes * refactor(src/pytest_plugins/help): Enforce all execution-specs mypy rule * refactor(src/pytest_plugins/eels_resolver): Enforce all execution-specs mypy rule refactor(plugins/eels_resolver): More fixes * refactor(src/pytest_plugins/fix_package_test_path): Enforce all execution-specs mypy rule * refactor(src/pytest_plugins/execute): Enforce all execution-specs mypy rule refactor(plugins/execute): More fixes * refactor(plugins/consume): Enforce all execution-specs mypy rules * refactor(src/pytest_plugins/filler): Enforce all execution-specs mypy rule refactor(plugins/filler): More fixes * refactor(src/pytest_plugins/spec_version_checker): Enforce all execution-specs mypy rule * refactor(src/pytest_plugins/pytest_hive): Enforce all execution-specs mypy rule * refactor(plugins/shared): Enforce all execution-specs mypy rules --------- Co-authored-by: LouisTsai <[email protected]> Co-authored-by: fselmo <[email protected]>
1 parent 82408b4 commit ca37419

File tree

402 files changed

+2872
-2392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

402 files changed

+2872
-2392
lines changed

.github/scripts/generate_eip_report.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import textwrap
1010
from string import Template
11+
from typing import List, Tuple
1112

1213
# Report template using textwrap.dedent for clean multiline strings
1314
REPORT_TEMPLATE = Template(
@@ -49,7 +50,7 @@
4950
)
5051

5152

52-
def extract_failures(output):
53+
def extract_failures(output: str) -> List[Tuple[str, str, str, str, str, str]]:
5354
"""Extract failure information from the output using regex."""
5455
failures = []
5556

@@ -88,7 +89,7 @@ def extract_failures(output):
8889
return failures
8990

9091

91-
def generate_summary_table(failures):
92+
def generate_summary_table(failures: List[Tuple[str, str, str, str, str, str]]) -> str:
9293
"""Generate a markdown summary table from the failures."""
9394
rows = []
9495
for file_path, eip_num, _, eip_link, ref_version, latest_version in failures:
@@ -98,7 +99,7 @@ def generate_summary_table(failures):
9899
return "\n".join(rows)
99100

100101

101-
def main():
102+
def main() -> None:
102103
"""Generate the report."""
103104
if len(sys.argv) < 2:
104105
print("Usage: uv run python generate_eip_report.py <input_file> [output_file]")

.github/scripts/get_release_props.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
@click.command()
1919
@click.argument("release", required=True)
20-
def get_release_props(release):
20+
def get_release_props(release: str) -> None:
2121
"""Extract the properties from the YAML file for a given release."""
2222
with open(RELEASE_PROPS_FILE) as f:
2323
data = yaml.safe_load(f)

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ exclude = [
190190
'^site/',
191191
]
192192
plugins = ["pydantic.mypy"]
193-
# more rules
194193
namespace_packages = true
195194
strict_optional = true
195+
disallow_incomplete_defs = true
196+
disallow_untyped_defs = true
196197
strict_bytes = true
197198
warn_unused_ignores = true
198199
warn_unused_configs = true

src/cli/check_fixtures.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def count_json_files_exclude_index(start_path: Path) -> int:
2323
return json_file_count
2424

2525

26-
def check_json(json_file_path: Path):
26+
def check_json(json_file_path: Path) -> None:
2727
"""
2828
Check all fixtures in the specified json file:
2929
1. Load the json file into a pydantic model. This checks there are no
@@ -50,11 +50,15 @@ def check_json(json_file_path: Path):
5050
)
5151
if "hash" in fixture.info and fixture.info["hash"] != original_hash:
5252
info_hash = fixture.info["hash"]
53+
info_hash_str = str(info_hash) if not isinstance(info_hash, str) else info_hash
5354
raise HashMismatchExceptionError(
5455
original_hash,
55-
fixture.info["hash"],
56-
message=f"Fixture info['hash'] does not match calculated hash for {fixture_name}:"
57-
f"'{info_hash}' != '{original_hash}'",
56+
info_hash_str,
57+
message=(
58+
f"Fixture info['hash'] does not match calculated "
59+
f"hash for {fixture_name}: '{info_hash}' != "
60+
f"'{original_hash}'"
61+
),
5862
)
5963

6064

@@ -86,9 +90,9 @@ def check_json(json_file_path: Path):
8690
expose_value=True,
8791
help="Stop and raise any exceptions encountered while checking fixtures.",
8892
)
89-
def check_fixtures(input_str: str, quiet_mode: bool, stop_on_error: bool):
93+
def check_fixtures(input_str: str, quiet_mode: bool, stop_on_error: bool) -> bool:
9094
"""
91-
Perform some checks on the fixtures contained in the specified directory.
95+
Perform checks on fixtures in the specified directory.
9296
"""
9397
input_path = Path(input_str)
9498
success = True

src/cli/compare_fixtures.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def pop_all_by_hash(index: IndexFile, fixture_hash: HexNumber) -> List[TestCaseI
6565
return test_cases
6666

6767

68-
def remove_fixture_from_file(file: Path, test_case_id: str):
68+
def remove_fixture_from_file(file: Path, test_case_id: str) -> None:
6969
"""Remove a single fixture by its ID from a generic fixture file."""
7070
try:
7171
# Load from json to a dict
@@ -78,7 +78,7 @@ def remove_fixture_from_file(file: Path, test_case_id: str):
7878
raise KeyError(f"Test case {test_case_id} not found in {file}") from None
7979

8080

81-
def batch_remove_fixtures_from_files(removals_by_file):
81+
def batch_remove_fixtures_from_files(removals_by_file: dict[Path, list[str]]) -> None:
8282
"""Batch process file removals to minimize I/O."""
8383
for file_path, test_case_ids in removals_by_file.items():
8484
try:
@@ -93,10 +93,9 @@ def batch_remove_fixtures_from_files(removals_by_file):
9393
print(f"Error processing {file_path}: {e}")
9494

9595

96-
def rewrite_index(folder: Path, index: IndexFile, dry_run: bool):
96+
def rewrite_index(folder: Path, index: IndexFile, dry_run: bool) -> None:
9797
"""
98-
Rewrite the index to the correct index file, or if the test count was
99-
reduced to zero, the entire directory is deleted.
98+
Rewrite index to file, or if test count is zero, delete directory.
10099
"""
101100
if len(index.test_cases) > 0:
102101
# Just rewrite the index
@@ -129,9 +128,9 @@ def main(
129128
patch: Path,
130129
dry_run: bool,
131130
abort_on_empty_patch: bool,
132-
):
131+
) -> None:
133132
"""
134-
Compare two fixture folders and remove duplicates based on fixture hashes.
133+
Compare two folders and remove duplicates based on fixture hashes.
135134
"""
136135
try:
137136
# Load indices

src/cli/diff_opcode_counts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ def main(
128128
show_common: bool,
129129
show_missing: bool,
130130
remove_from_fixture_names: List[str],
131-
):
132-
"""Crawl two folders, compare and print the opcode count diffs."""
131+
) -> None:
132+
"""Crawl two folders, compare and print opcode count diffs."""
133133
print(f"Loading opcode counts from {base}...")
134134
opcode_counts1 = load_all_opcode_counts(base, remove_from_fixture_names)
135135
print(f"Found {len(opcode_counts1)} fixtures with opcode counts")

src/cli/eest/cli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
from .make.cli import make
1010

1111

12-
@click.group(context_settings={"help_option_names": ["-h", "--help"], "max_content_width": 120})
13-
def eest():
12+
@click.group(
13+
context_settings={
14+
"help_option_names": ["-h", "--help"],
15+
"max_content_width": 120,
16+
}
17+
)
18+
def eest() -> None:
1419
"""`eest` is a CLI tool that helps with routine tasks."""
1520
pass
1621

src/cli/eest/commands/clean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
)
1717
@click.option("--dry-run", is_flag=True, help="Simulate the cleanup without removing files.")
1818
@click.option("-v", "--verbose", is_flag=True, help="Show verbose output.")
19-
def clean(all_files: bool, dry_run: bool, verbose: bool):
19+
def clean(all_files: bool, dry_run: bool, verbose: bool) -> None:
2020
"""
2121
Remove all generated files and directories from the repository.
2222

src/cli/eest/commands/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def get_uv_version() -> str:
3030

3131

3232
@click.command(name="info")
33-
def info():
33+
def info() -> None:
3434
"""Display EEST and system information."""
3535
# Format headers
3636
title = click.style("EEST", fg="green", bold=True)

src/cli/eest/make/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
@click.group(short_help="Generate project files.")
20-
def make():
20+
def make() -> None:
2121
"""Generate project files."""
2222
pass
2323

0 commit comments

Comments
 (0)