Skip to content

chore: add codespell pre-commit hook to catch typos#6406

Open
anxkhn wants to merge 1 commit into
google:mainfrom
anxkhn:chore/add-codespell
Open

chore: add codespell pre-commit hook to catch typos#6406
anxkhn wants to merge 1 commit into
google:mainfrom
anxkhn:chore/add-codespell

Conversation

@anxkhn

@anxkhn anxkhn commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

2. Or, if no issue exists, describe the change:

Problem:

There is no automated spell checker in the pre-commit config or CI. The
.pre-commit-config.yaml runs ruff, isort, pyink, addlicense, and mdformat, but
nothing catches misspellings, so typos land in source, docstrings, samples, and
comments and are only fixed later by occasional one-off reader-submitted PRs.

Solution:

Add a codespell hook so typos
are caught automatically, both locally on commit and in CI.

  • .pre-commit-config.yaml: add the codespell hook (rev: v2.4.2) with
    additional_dependencies: [tomli] so it can read its config from
    pyproject.toml. The existing lint CI job already runs
    pre-commit/action with no extra args, so the new hook becomes a CI gate
    automatically. No separate workflow job is added, keeping the change minimal.
  • pyproject.toml: add a [tool.codespell] table with a small, tuned
    ignore-words-list (genuine false positives only: the ROUGE metric, a couple
    of test-fixture substrings, a local variable name, and intentional
    hyphenation) and a skip list for generated/data files (CHANGELOG, lockfiles,
    notebooks, JSON fixtures, bundled JS/source maps, and the vendored CLI browser
    bundle).
  • Fix the existing typos codespell currently flags so the tree stays green
    honestly (typos are fixed, not buried in the ignore list): Initiaze ->
    Initialize, build-in -> built-in, relavant -> relevant, anwer ->
    answer (samples); Coverts -> Converts, exsisting -> existing,
    ouput -> output, incase -> in case, retreving -> retrieving
    (source); simplfy -> simplify, successfull -> successful (test
    comments).

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

This is a tooling and typo change (no runtime behavior changes), so no new unit
tests are added. The edits are limited to comments, docstrings, sample text, and
one JSON schema description string; no test asserts on the changed strings.

Verification run locally:

  • pre-commit run codespell --all-files -> Passed (exit 0).
  • codespell (v2.4.2) bare walk, auto-reading pyproject.toml -> exit 0.
  • Full pre-commit suite over the change -> all hooks Passed.
  • Targeted pytest on the files with edited comments:
    • tests/unittests/a2a/executor/test_a2a_agent_executor.py -> 25 passed.
    • tests/unittests/integrations/bigquery/test_bigquery_query_tool.py ->
      92 passed.
    • tests/unittests/tools/application_integration_tool/ (covers the edited
      connections_client.py schema description) -> 78 passed.

Manual End-to-End (E2E) Tests:

Not applicable: no user-facing runtime or UI behavior changes. The hook can be
exercised with pre-commit run codespell --all-files.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

The ignore list is intentionally minimal so codespell keeps catching real typos
(verified it still flags things like teh and recieve); only genuine false
positives are suppressed. Happy to drop the source/sample typo fixes into a
separate PR, or split the tool from the fixes, if the maintainers prefer.

The repo has no automated spell check, so misspellings only get caught by
occasional reader-submitted typo PRs. Add a codespell hook to
.pre-commit-config.yaml (already run in CI via pre-commit/action) with a
[tool.codespell] table in pyproject.toml, tuned to skip generated/data files
and ignore genuine false positives (the ROUGE metric, test-fixture substrings,
a local variable, intentional hyphenation). Fix the existing typos codespell
flags so the tree stays green.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
@adk-bot adk-bot added the tools [Component] This issue is related to tools label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants