From 098b9d80e79bde5e217f1981f93ac83ed4f0ace5 Mon Sep 17 00:00:00 2001 From: Anas Khan <83116240+anxkhn@users.noreply.github.com> Date: Sat, 4 Jul 2026 00:37:28 +0530 Subject: [PATCH] chore: add codespell pre-commit hook to catch typos 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> --- .pre-commit-config.yaml | 8 ++++++++ contributing/samples/integrations/data_agent/agent.py | 2 +- .../integrations/oauth_calendar_agent/agent.py | 2 +- .../samples/integrations/spanner_rag_agent/README.md | 2 +- contributing/samples/workflows/route/agent.py | 2 +- pyproject.toml | 11 +++++++++++ .../evaluation/rubric_based_tool_use_quality_v1.py | 2 +- src/google/adk/runners.py | 2 +- .../clients/connections_client.py | 2 +- src/google/adk/workflow/_function_node.py | 2 +- .../unittests/a2a/executor/test_a2a_agent_executor.py | 2 +- .../integrations/bigquery/test_bigquery_query_tool.py | 2 +- 12 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 37d6d5cc173..bbfbe549528 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,3 +72,11 @@ repos: exclude: (?i)SKILL\.md$ additional_dependencies: - mdformat-gfm + - repo: https://github.com/codespell-project/codespell + rev: v2.4.2 + hooks: + - id: codespell + # Configuration (skip globs, ignored words) lives in the + # [tool.codespell] table in pyproject.toml. + additional_dependencies: + - tomli diff --git a/contributing/samples/integrations/data_agent/agent.py b/contributing/samples/integrations/data_agent/agent.py index 696430cf06f..c71fc5e4b30 100644 --- a/contributing/samples/integrations/data_agent/agent.py +++ b/contributing/samples/integrations/data_agent/agent.py @@ -36,7 +36,7 @@ CREDENTIALS_TYPE = None if CREDENTIALS_TYPE == AuthCredentialTypes.OAUTH2: - # Initiaze the tools to do interactive OAuth + # Initialize the tools to do interactive OAuth # The environment variables OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET # must be set credentials_config = DataAgentCredentialsConfig( diff --git a/contributing/samples/integrations/oauth_calendar_agent/agent.py b/contributing/samples/integrations/oauth_calendar_agent/agent.py index 981b942f01f..00e70de88eb 100644 --- a/contributing/samples/integrations/oauth_calendar_agent/agent.py +++ b/contributing/samples/integrations/oauth_calendar_agent/agent.py @@ -42,7 +42,7 @@ SCOPES = ["https://www.googleapis.com/auth/calendar"] calendar_toolset = CalendarToolset( - # you can also replace below customized `list_calendar_events` with build-in + # you can also replace below customized `list_calendar_events` with built-in # google calendar tool by adding `calendar_events_list` in the filter list client_id=oauth_client_id, client_secret=oauth_client_secret, diff --git a/contributing/samples/integrations/spanner_rag_agent/README.md b/contributing/samples/integrations/spanner_rag_agent/README.md index c475eff5c0c..ae9a1b699b7 100644 --- a/contributing/samples/integrations/spanner_rag_agent/README.md +++ b/contributing/samples/integrations/spanner_rag_agent/README.md @@ -296,7 +296,7 @@ There are a few options to perform similarity search: "from the Spanner database." ), instruction=""" - You are a helpful assistant that answers user questions to find the most relavant information from a Spanner database. + You are a helpful assistant that answers user questions to find the most relevant information from a Spanner database. 1. Always use the `similarity_search` tool to find relevant information. 2. If no relevant information is found, say you don't know. 3. Present all the relevant information naturally and well formatted in your response. diff --git a/contributing/samples/workflows/route/agent.py b/contributing/samples/workflows/route/agent.py index 1722e94de60..e70f64045d9 100644 --- a/contributing/samples/workflows/route/agent.py +++ b/contributing/samples/workflows/route/agent.py @@ -57,7 +57,7 @@ def route_on_category(category: InputCategory): def handle_other(): yield Event( - message="Sorry I can only anwer questions or comment on statements." + message="Sorry I can only answer questions or comment on statements." ) diff --git a/pyproject.toml b/pyproject.toml index dee3e5721f8..33c83fedf37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -296,6 +296,17 @@ line_length = 200 single_line_exclusions = [] known_third_party = [ "a2a", "google.adk" ] +[tool.codespell] +# Real words/identifiers that codespell misreads as typos: +# hel/serie/strin -> substrings in test fixtures; te -> local variable; +# rouge -> the ROUGE metric; unparseable -> valid spelling variant; +# re-use/re-used -> intentional hyphenation. +ignore-words-list = "hel,serie,strin,te,rouge,unparseable,re-use,re-used" +# CHANGELOG.md is generated from commit messages; lockfiles, notebooks, JSON +# fixtures, bundled JS/source maps, and the vendored CLI browser bundle are +# generated or data files, not prose we own. +skip = "*CHANGELOG.md,*.lock,*.ipynb,*.json,*.js,*.map,*/cli/browser/*" + [tool.mypy] mypy_path = [ "src" ] exclude = [ "contributing/samples/", "tests/" ] diff --git a/src/google/adk/evaluation/rubric_based_tool_use_quality_v1.py b/src/google/adk/evaluation/rubric_based_tool_use_quality_v1.py index d8d1da94c57..dcb7620fe4b 100644 --- a/src/google/adk/evaluation/rubric_based_tool_use_quality_v1.py +++ b/src/google/adk/evaluation/rubric_based_tool_use_quality_v1.py @@ -130,7 +130,7 @@ class RubricBasedToolUseV1Evaluator(RubricBasedEvaluator): """An Evaluator for rubric based assessment of the agent's usage of Tools. Example: Lets take an example of a Weather Agent that has access to two tools: - 1: GeoCoding Tool: Coverts a city name, address or zip code into geographic + 1: GeoCoding Tool: Converts a city name, address or zip code into geographic coordinates. 2: GetWeather Tool: Gets weather for the next 10 days for the given geographic coordinates. diff --git a/src/google/adk/runners.py b/src/google/adk/runners.py index bc90b9421cf..adfd7e84e8f 100644 --- a/src/google/adk/runners.py +++ b/src/google/adk/runners.py @@ -1631,7 +1631,7 @@ async def run_live( * **Other Control Events:** Most control events are saved. **Events Saved to the Session:** - * **Live Model Audio Events with File Data:** Both input and ouput audio + * **Live Model Audio Events with File Data:** Both input and output audio data are aggregated into an audio file saved into artifacts. The reference to the file is saved as event in the `file_data` to session if RunConfig.save_live_model_audio_to_session is True. diff --git a/src/google/adk/tools/application_integration_tool/clients/connections_client.py b/src/google/adk/tools/application_integration_tool/clients/connections_client.py index c33c9c44249..4e533190563 100644 --- a/src/google/adk/tools/application_integration_tool/clients/connections_client.py +++ b/src/google/adk/tools/application_integration_tool/clients/connections_client.py @@ -247,7 +247,7 @@ def get_connector_base_spec() -> Dict[str, Any]: "host": { "type": "string", "default": "", - "description": "Host name incase of tls service directory", + "description": "Host name in case of tls service directory", }, "entity": { "type": "string", diff --git a/src/google/adk/workflow/_function_node.py b/src/google/adk/workflow/_function_node.py index 15670634af2..61c9d9d54e4 100644 --- a/src/google/adk/workflow/_function_node.py +++ b/src/google/adk/workflow/_function_node.py @@ -476,7 +476,7 @@ def model_copy( # If the wrapped function is a bound method of a Node, we need to clone # the Node and re-bind the function to the new instance. # This is needed if the function is referring to params like 'name' from the "self" reference. - # Like Workflow or LLM use that name for event node_paths or retreving session events. + # Like Workflow or LLM use that name for event node_paths or retrieving session events. func = self._func if inspect.ismethod(func) and isinstance( getattr(func, '__self__', None), BaseNode diff --git a/tests/unittests/a2a/executor/test_a2a_agent_executor.py b/tests/unittests/a2a/executor/test_a2a_agent_executor.py index c5e0b13d822..70511dd1e07 100644 --- a/tests/unittests/a2a/executor/test_a2a_agent_executor.py +++ b/tests/unittests/a2a/executor/test_a2a_agent_executor.py @@ -1154,7 +1154,7 @@ async def mock_run_async(**kwargs): ) self.mock_runner._new_invocation_context.return_value = Mock() - # We patch TaskResultAggregator just to avoid other errors and simplfy + # We patch TaskResultAggregator just to avoid other errors and simplify with patch( "google.adk.a2a.executor.a2a_agent_executor.TaskResultAggregator" ) as mock_agg_class: diff --git a/tests/unittests/integrations/bigquery/test_bigquery_query_tool.py b/tests/unittests/integrations/bigquery/test_bigquery_query_tool.py index 3a851014a8a..01f5466afc8 100644 --- a/tests/unittests/integrations/bigquery/test_bigquery_query_tool.py +++ b/tests/unittests/integrations/bigquery/test_bigquery_query_tool.py @@ -2183,7 +2183,7 @@ def test_tool_call_doesnt_change_global_settings(tool_call): # Call the tool result = tool_call(settings, tool_context) - # Test successfull executeion of the tool + # Test successful executeion of the tool assert result == {"status": "SUCCESS", "rows": []} # Test settings write mode after