Skip to content

Commit 8c3cbd7

Browse files
authored
chore(deps,tooling,ci): replace pyspelling with codespell in tox (#1715)
* chore(deps): add `codespell` to the `docs` extras group * feat(tooling,tox,ci): use `codespell` instead of `pyspelling` * docs(tooling,ci): update docs for `codespell` * chore(tooling): run spellecheck in precommit for python * chore(ci): update ci flow for `codespell` -> `pyspelling` * chore(all): fix the typos * chore(tests): fix typo in function name * docs: update changelog
1 parent d6252aa commit 8c3cbd7

File tree

62 files changed

+247
-99
lines changed

Some content is hidden

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

62 files changed

+247
-99
lines changed

.github/workflows/coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
echo "No python files were changed in ./tests/ - no action necessary"
4444
exit 0
4545
46-
- name: Report changed python test moudules
46+
- name: Report changed python test modules
4747
if: steps.changed-tests.outputs.tests_any_changed == 'true'
4848
run: |
4949
echo "${{ toJson(steps.changed-tests.outputs) }}"

.github/workflows/tox_verify.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: uvx --with=tox-uv tox -e typecheck
3737

3838
spellcheck:
39-
name: Spellcheck sources with pyspelling
39+
name: Spellcheck sources with codespell
4040
runs-on: ubuntu-latest
4141
steps:
4242
- name: Checkout ethereum/execution-spec-tests
@@ -48,11 +48,10 @@ jobs:
4848
cache-dependency-glob: "uv.lock"
4949
version: ${{ vars.UV_VERSION }}
5050
python-version: ${{ vars.DEFAULT_PYTHON_VERSION }}
51-
- name: Install dependencies (aspell, aspell-en)
52-
run: |
53-
sudo apt-get update && sudo apt-get install -y aspell aspell-en
54-
- name: Run spellcheck with pyspelling via tox
51+
- name: Run spellcheck with codespell via tox
5552
run: uvx --with=tox-uv tox -e spellcheck
53+
env:
54+
GITHUB_STEP_SUMMARY: ${{ env.GITHUB_STEP_SUMMARY }}
5655

5756
markdownlint:
5857
name: Lint markdown files with markdownlint

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
hooks:
44
- id: tox
55
name: tox
6-
entry: uvx --with=tox-uv tox --parallel -e lint,typecheck
6+
entry: uvx --with=tox-uv tox --parallel -e lint,typecheck,spellcheck
77
language: system
88
types: [python]
99
pass_filenames: false

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Users can select any of the artifacts depending on their testing needs for their
4949
- ✨ Added [Post-Mortems of Missed Test Scenarios](https://eest.ethereum.org/main/writing_tests/post_mortems/) to the documentation that serves as a reference list of all cases that were missed during the test implementation phase of a new EIP, and includes the steps taken in order to prevent similar test cases to be missed in the future ([#1327](https://github.com/ethereum/execution-spec-tests/pull/1327)).
5050
- ✨ Added a new `eest` sub-command, `eest info`, to easily print a cloned EEST repository's version and the versions of relevant tools, e.g., `python`, `uv` ([#1621](https://github.com/ethereum/execution-spec-tests/pull/1621)).
5151
- ✨ Add `CONTRIBUTING.md` for execution-spec-tests and improve coding standards documentation ([#1604](https://github.com/ethereum/execution-spec-tests/pull/1604)).
52+
- ✨ Use `codespell` instead of `pyspelling` to spell-check python and markdown sources ([#1715](https://github.com/ethereum/execution-spec-tests/pull/1715)).
5253
- 🔀 Updated from pytest 7 to [pytest 8](https://docs.pytest.org/en/stable/changelog.html#features-and-improvements), benefits include improved type hinting and hook typing, stricter mark handling, and clearer error messages for plugin and metadata development ([#1433](https://github.com/ethereum/execution-spec-tests/pull/1433)).
5354
- 🐞 Fix bug in ported-from plugin and coverage script that made PRs fail with modified tests that contained no ported tests ([#1661](https://github.com/ethereum/execution-spec-tests/pull/1661)).
5455
- 🔀 Refactor the `click`-based CLI interface used for pytest-based commands (`fill`, `execute`, `consume`) to make them more extensible ([#1654](https://github.com/ethereum/execution-spec-tests/pull/1654)).

docs/executing_tests/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ uv run execute remote --fork=Prague --rpc-endpoint=https://rpc.endpoint.io --rpc
106106

107107
## `execute` Command Test Execution
108108

109-
After executing wither `execute hive` or `execute remote`, the command will first create a random sender account from which all required test accounts will be deployed and funded, and this account is funded by sweeping (by default) the seed account.
109+
After executing `execute hive` or `execute remote` the command will first create a random sender account from which all required test accounts will be deployed and funded, and this account is funded by sweeping (by default) the seed account.
110110

111111
The sweep amount can be configured by setting the `--seed-account-sweep-amount` flag:
112112

docs/getting_started/code_standards.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Code pushed to @ethereum/execution-spec-tests must fulfill the following checks
1414
| EL Client test cases | `uvx --with=tox-uv tox -e tests-deployed` | All client test cases for deployed forks can be generated. |
1515
| zkEVM EL Test cases | `uvx --with=tox-uv tox -e tests-deployed-zkevm` | All client test cases specific to zkEVMs for deployed forks can be generated. |
1616
| HTML doc build | `uvx --with=tox-uv tox -e mkdocs` | Documentation generated without warnings. |
17-
| Spellcheck | `uvx --with=tox-uv tox -e spellcheck` | Markdown spell-check (requires [additional dependency](code_standards_details.md#additional-dependencies)). |
17+
| Spellcheck | `uvx --with=tox-uv tox -e spellcheck` | Code and documentation spell-check using codespell. |
1818
| Markdown lint | `uvx --with=tox-uv tox -e markdownlint` | Markdown lint (requires [additional dependency](code_standards_details.md#additional-dependencies)). |
1919

2020
!!! tip "Running checks easily"

docs/getting_started/code_standards_details.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,17 @@ Some checks require external (non-Python) packages:
5959

6060
#### For `spellcheck`
6161

62+
The spellcheck environment uses **codespell**, which is automatically installed via Python dependencies and checks for common spelling mistakes in code and documentation.
63+
64+
To fix spelling errors found by codespell:
65+
6266
```console
63-
sudo apt-get install aspell aspell-en
67+
uv run codespell *.md *.ini .github/ src/ tests/ docs/ --write-changes
6468
```
6569

70+
!!! note "VS Code Integration"
71+
The `whitelist.txt` file is still maintained for the VS Code cSpell extension, which provides real-time spell checking in the editor.
72+
6673
#### For `markdownlint`
6774

6875
```console

pyproject.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ Changelog = "https://eest.ethereum.org/main/CHANGELOG/"
6161

6262
[project.optional-dependencies]
6363
test = ["pytest-cov>=4.1.0,<5"]
64-
lint = [
65-
"ruff==0.11.8",
66-
"mypy>=1.15.0,<1.16",
67-
"types-requests>=2.31,<2.33",
68-
]
64+
lint = ["ruff==0.11.8", "mypy>=1.15.0,<1.16", "types-requests>=2.31,<2.33"]
6965
docs = [
7066
"cairosvg>=2.7.0,<3",
67+
"codespell>=2.4.1,<3",
7168
"mike>=1.1.2,<2",
7269
"mkdocs>=1.4.3,<2",
7370
"mkdocs-click>=0.8,<1",
@@ -124,10 +121,14 @@ select = ["E", "F", "B", "W", "I", "A", "N", "D", "C"]
124121
fixable = ["I", "B", "E", "F", "W", "D", "C"]
125122
ignore = ["D205", "D203", "D212", "D415", "C901", "A005", "C420"]
126123

127-
128124
[tool.mypy]
129125
mypy_path = ["src", "$MYPY_CONFIG_FILE_DIR/stubs"]
130126
plugins = ["pydantic.mypy"]
131127

128+
[tool.codespell]
129+
skip = ".venv,__pycache__,.git,build,dist,*.pyc,*.lock"
130+
check-filenames = true
131+
ignore-words-list = "ingenuous"
132+
132133
[tool.uv.sources]
133134
ethereum-spec-evm-resolver = { git = "https://github.com/petertdavies/ethereum-spec-evm-resolver", rev = "623ac4565025e72b65f45b926da2a3552041b469" }

src/cli/tox_helpers.py

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,41 @@
1313

1414
import click
1515
from pyspelling import __main__ as pyspelling_main # type: ignore
16+
from rich.console import Console
17+
18+
19+
def write_github_summary(title: str, tox_env: str, error_message: str, fix_commands: list[str]):
20+
"""
21+
Write a summary to GitHub Actions when a check fails.
22+
23+
Args:
24+
title: The title of the check that failed
25+
tox_env: The tox environment name (e.g., "spellcheck")
26+
error_message: Description of what went wrong
27+
fix_commands: List of commands to fix the issue locally
28+
29+
"""
30+
if not os.environ.get("GITHUB_ACTIONS"):
31+
return
32+
33+
summary_file = os.environ.get("GITHUB_STEP_SUMMARY")
34+
if not summary_file:
35+
return
36+
37+
with open(summary_file, "a") as f:
38+
f.write(f"## ❌ {title}\n\n")
39+
f.write(f"{error_message}\n\n")
40+
f.write("### To reproduce this check locally:\n")
41+
f.write("```bash\n")
42+
f.write(f"uvx --with=tox-uv tox -e {tox_env}\n")
43+
f.write("```\n\n")
44+
45+
if fix_commands:
46+
f.write("### To verify and fix the issues:\n")
47+
f.write("```bash\n")
48+
for cmd in fix_commands:
49+
f.write(f"{cmd}\n")
50+
f.write("```\n")
1651

1752

1853
@click.command(
@@ -57,11 +92,97 @@ def pyspelling():
5792
if not shutil.which("aspell"):
5893
click.echo("aspell not installed, skipping spellcheck.")
5994
if os.environ.get("GITHUB_ACTIONS"):
95+
write_github_summary(
96+
title="Pyspelling Check Failed",
97+
tox_env="spellcheck",
98+
error_message=(
99+
"aspell is not installed. This tool is required for spell checking "
100+
" documentation."
101+
),
102+
fix_commands=[
103+
"# Install aspell on Ubuntu/Debian",
104+
"sudo apt-get install aspell aspell-en",
105+
"",
106+
"# Install aspell on macOS",
107+
"brew install aspell",
108+
],
109+
)
60110
sys.exit(1)
61111
else:
62112
click.echo(
63113
"********* Install 'aspell' and 'aspell-en' to enable spellcheck *********"
64114
)
65115
sys.exit(0)
66116

67-
sys.exit(pyspelling_main.main())
117+
result = pyspelling_main.main()
118+
if result != 0:
119+
write_github_summary(
120+
title="Pyspelling Check Failed",
121+
tox_env="spellcheck",
122+
error_message="Pyspelling found spelling errors in the documentation.",
123+
fix_commands=[
124+
"# Check the pyspelling configuration",
125+
"cat .pyspelling.yml",
126+
"",
127+
"# Review and fix spelling errors manually",
128+
"# Pyspelling doesn't have an auto-fix option",
129+
],
130+
)
131+
sys.exit(result)
132+
133+
134+
@click.command()
135+
def codespell():
136+
"""
137+
Run codespell on the codebase and provide helpful error messages.
138+
139+
Checks spelling in .github/, src/, tests/, and docs/ directories.
140+
"""
141+
console = Console()
142+
143+
# Define the paths to check
144+
paths_to_check = ["*.md", "*.ini", ".github/", "src/", "tests/", "docs/"]
145+
paths_str = " ".join(paths_to_check)
146+
147+
# Run codespell
148+
result = subprocess.run(
149+
["codespell"] + paths_to_check,
150+
capture_output=True,
151+
text=True,
152+
)
153+
154+
# Print the output
155+
if result.stdout:
156+
console.print(result.stdout)
157+
if result.stderr:
158+
console.print(result.stderr, style="red")
159+
160+
# If there were spelling errors, show a helpful message
161+
if result.returncode != 0:
162+
console.print("\n[bold red]❌ Spellcheck Failed[/bold red]")
163+
console.print(
164+
"[yellow]Please review the errors above. For single-suggestion fixes, you can "
165+
"automatically apply them with:[/yellow]"
166+
)
167+
console.print(f"[cyan]uv run codespell {paths_str} --write-changes[/cyan]\n")
168+
169+
# Write to GitHub Actions summary
170+
write_github_summary(
171+
title="Spellcheck Failed",
172+
tox_env="spellcheck",
173+
error_message="Codespell found spelling errors in the code.",
174+
fix_commands=[
175+
"# Ensure codespell is installed (part of docs extras)",
176+
"uv sync --all-extras",
177+
"",
178+
"# Check for spelling errors",
179+
f"uv run codespell {paths_str}",
180+
"",
181+
"# Automatically fix single-suggestion errors",
182+
f"uv run codespell {paths_str} --write-changes",
183+
],
184+
)
185+
186+
sys.exit(1)
187+
188+
sys.exit(0)

src/ethereum_clis/clis/besu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(
6161
def start_server(self):
6262
"""
6363
Start the t8n-server process, extract the port, and leave it running
64-
for future re-use.
64+
for future reuse.
6565
"""
6666
args = [
6767
str(self.binary),

0 commit comments

Comments
 (0)