mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Fix spelling
Merge https://github.com/google/adk-python/pull/2447 This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling) The misspellings have been reported at https://github.com/jsoref/adk-python/actions/runs/16840838898/attempts/1#summary-47711379253 The action reports that the changes in this PR would make it happy: https://github.com/jsoref/adk-python/actions/runs/16840839269/attempts/1#summary-47711380479 Note: while I use tooling to identify errors, the tooling doesn't _actually_ provide the corrections, I'm picking them on my own. I'm a human, and I may make mistakes. I've included a couple of changes to make CI happy. Personally, I object to CI being in a state of "random drive by person who adds a blank line in the middle of a file must fix all the preexisting bugs in the file", but that appears to be the state for this repository. COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/2447 from jsoref:spelling d85398e7fd154d124d477c6af6181481a01f34e0 PiperOrigin-RevId: 827629615
This commit is contained in:
committed by
Copybara-Service
parent
8dff85099d
commit
aa1233608a
@@ -368,7 +368,7 @@ class TestIntegration:
|
||||
assert result is not None
|
||||
assert (
|
||||
result.user_id == "A2A_USER_test_session_456"
|
||||
) # Should fallback to context ID
|
||||
) # Should fall back to context ID
|
||||
assert result.session_id == "test_session_456"
|
||||
assert isinstance(result.new_message, genai_types.Content)
|
||||
assert result.new_message.role == "user"
|
||||
|
||||
@@ -331,7 +331,7 @@ class TestHelperFunctions:
|
||||
assert result == "I should do my work and it will be mine."
|
||||
|
||||
def test_replace_pronouns_case_insensitive(self):
|
||||
"""Test _replace_pronouns with case insensitive matching."""
|
||||
"""Test _replace_pronouns with case-insensitive matching."""
|
||||
# Arrange
|
||||
text = "YOU should do YOUR work and it will be YOURS."
|
||||
|
||||
@@ -1073,7 +1073,7 @@ class TestExampleExtractionFunctions:
|
||||
assert result is None
|
||||
|
||||
def test_extract_examples_from_instruction_case_insensitive(self):
|
||||
"""Test _extract_examples_from_instruction with case insensitive matching."""
|
||||
"""Test _extract_examples_from_instruction with case-insensitive matching."""
|
||||
# Arrange
|
||||
instruction = (
|
||||
'example query: "What is the weather?" example response: "The weather'
|
||||
|
||||
@@ -274,7 +274,7 @@ def test_clone_invalid_field():
|
||||
"""Test that cloning with invalid fields raises an error."""
|
||||
original = LlmAgent(name="test_agent", description="Test agent")
|
||||
|
||||
with pytest.raises(ValueError, match="Cannot update non-existent fields"):
|
||||
with pytest.raises(ValueError, match="Cannot update nonexistent fields"):
|
||||
original.clone(update={"invalid_field": "value"})
|
||||
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ class TestRemoteA2aAgentResolution:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_resolve_agent_card_from_file_not_found(self):
|
||||
"""Test agent card resolution from non-existent file raises error."""
|
||||
"""Test agent card resolution from nonexistent file raises error."""
|
||||
agent = RemoteA2aAgent(
|
||||
name="test_agent", agent_card="/path/to/nonexistent.json"
|
||||
)
|
||||
|
||||
@@ -126,7 +126,7 @@ class TestCredentialExchangerRegistry:
|
||||
assert isinstance(retrieved_exchanger, BaseCredentialExchanger)
|
||||
|
||||
def test_get_exchanger_nonexistent_type_returns_none(self):
|
||||
"""Test that get_exchanger returns None for non-existent credential types."""
|
||||
"""Test that get_exchanger returns None for nonexistent credential types."""
|
||||
registry = CredentialExchangerRegistry()
|
||||
|
||||
# Try to get an exchanger that was never registered
|
||||
|
||||
@@ -24,7 +24,7 @@ from google.adk.auth.auth_credential import AuthCredential
|
||||
from google.adk.auth.auth_credential import AuthCredentialTypes
|
||||
from google.adk.auth.auth_credential import OAuth2Auth
|
||||
from google.adk.auth.auth_schemes import OpenIdConnectWithConfig
|
||||
from google.adk.auth.exchanger.base_credential_exchanger import CredentialExchangError
|
||||
from google.adk.auth.exchanger.base_credential_exchanger import CredentialExchangeError
|
||||
from google.adk.auth.exchanger.oauth2_credential_exchanger import OAuth2CredentialExchanger
|
||||
import pytest
|
||||
|
||||
@@ -117,7 +117,7 @@ class TestOAuth2CredentialExchanger:
|
||||
try:
|
||||
await exchanger.exchange(credential, None)
|
||||
assert False, "Should have raised ValueError"
|
||||
except CredentialExchangError as e:
|
||||
except CredentialExchangeError as e:
|
||||
assert "auth_scheme is required" in str(e)
|
||||
|
||||
@patch("google.adk.auth.oauth2_credential_util.OAuth2Session")
|
||||
|
||||
@@ -419,7 +419,7 @@ class TestGetAuthResponse:
|
||||
assert result == oauth2_credentials_with_auth_uri
|
||||
|
||||
def test_get_auth_response_not_exists(self, auth_config):
|
||||
"""Test retrieving a non-existent auth response from state."""
|
||||
"""Test retrieving a nonexistent auth response from state."""
|
||||
handler = AuthHandler(auth_config)
|
||||
state = MockState()
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ class TestAgentLoader:
|
||||
loader = AgentLoader(temp_dir)
|
||||
agents_dir = temp_dir # For use in the expected message string
|
||||
|
||||
# Try to load non-existent agent
|
||||
# Try to load nonexistent agent
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
loader.load_agent("nonexistent_agent")
|
||||
|
||||
@@ -328,12 +328,12 @@ class TestAgentLoader:
|
||||
assert "No root_agent found for 'broken_agent'" in str(exc_info.value)
|
||||
|
||||
def test_agent_internal_module_not_found_error(self):
|
||||
"""Test error when an agent tries to import a non-existent module."""
|
||||
"""Test error when an agent tries to import a nonexistent module."""
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
temp_path = Path(temp_dir)
|
||||
agent_name = "importer_agent"
|
||||
|
||||
# Create agent that imports a non-existent module
|
||||
# Create agent that imports a nonexistent module
|
||||
agent_file = temp_path / f"{agent_name}.py"
|
||||
agent_file.write_text(dedent(f"""
|
||||
from google.adk.agents.base_agent import BaseAgent
|
||||
@@ -526,7 +526,7 @@ class TestAgentLoader:
|
||||
loader = AgentLoader(temp_dir)
|
||||
agents_dir = temp_dir # For use in the expected message string
|
||||
|
||||
# Try to load non-existent YAML agent
|
||||
# Try to load nonexistent YAML agent
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
loader.load_agent("nonexistent_yaml_agent")
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ def empty_state() -> State:
|
||||
|
||||
@pytest.fixture
|
||||
def context_with_data() -> CodeExecutorContext:
|
||||
"""Fixture for a CodeExecutorContext with some pre-populated data."""
|
||||
"""Fixture for a CodeExecutorContext with some prepopulated data."""
|
||||
state_data = {
|
||||
"_code_execution_context": {
|
||||
"execution_session_id": "session123",
|
||||
|
||||
@@ -101,7 +101,7 @@ class TestGcsEvalSetsManager:
|
||||
app_name = "test_app"
|
||||
eval_set_id = "invalid-id"
|
||||
|
||||
with pytest.raises(ValueError, match="Invalid Eval Set Id"):
|
||||
with pytest.raises(ValueError, match="Invalid Eval Set ID"):
|
||||
gcs_eval_sets_manager.create_eval_set(app_name, eval_set_id)
|
||||
|
||||
def test_gcs_eval_sets_manager_list_eval_sets_success(
|
||||
|
||||
@@ -527,7 +527,7 @@ def test_generate_final_eval_status_doesn_t_throw_on(eval_service):
|
||||
# eval case.
|
||||
|
||||
# We go over all the possible values of EvalStatus one by one and expect
|
||||
# the _generate_final_eval_status to handle it without throwing an exeception.
|
||||
# the _generate_final_eval_status to handle it without throwing an exception.
|
||||
for status in EvalStatus:
|
||||
eval_metric_result = EvalMetricResult(
|
||||
metric_name="metric1", threshold=0.5, eval_status=status
|
||||
|
||||
@@ -24,7 +24,7 @@ from google.adk.evaluation.eval_case import IntermediateData
|
||||
from google.adk.evaluation.eval_case import Invocation
|
||||
from google.adk.evaluation.eval_set import EvalSet
|
||||
from google.adk.evaluation.local_eval_sets_manager import _EVAL_SET_FILE_EXTENSION
|
||||
from google.adk.evaluation.local_eval_sets_manager import convert_eval_set_to_pydanctic_schema
|
||||
from google.adk.evaluation.local_eval_sets_manager import convert_eval_set_to_pydantic_schema
|
||||
from google.adk.evaluation.local_eval_sets_manager import load_eval_set_from_file
|
||||
from google.adk.evaluation.local_eval_sets_manager import LocalEvalSetsManager
|
||||
from google.genai import types as genai_types
|
||||
@@ -32,10 +32,10 @@ from pydantic import ValidationError
|
||||
import pytest
|
||||
|
||||
|
||||
class TestConvertEvalSetToPydancticSchema:
|
||||
"""Tests convert_eval_set_to_pydanctic_schema method."""
|
||||
class TestConvertEvalSetToPydanticSchema:
|
||||
"""Tests convert_eval_set_to_pydantic_schema method."""
|
||||
|
||||
def test_convert_eval_set_to_pydanctic_schema_complete(self):
|
||||
def test_convert_eval_set_to_pydantic_schema_complete(self):
|
||||
eval_set_id = "test_eval_set"
|
||||
eval_set_in_json_format = [{
|
||||
"name": "roll_17_sided_dice_twice",
|
||||
@@ -71,7 +71,7 @@ class TestConvertEvalSetToPydancticSchema:
|
||||
},
|
||||
}]
|
||||
|
||||
eval_set = convert_eval_set_to_pydanctic_schema(
|
||||
eval_set = convert_eval_set_to_pydantic_schema(
|
||||
eval_set_id, eval_set_in_json_format
|
||||
)
|
||||
|
||||
@@ -93,14 +93,14 @@ class TestConvertEvalSetToPydancticSchema:
|
||||
== 1
|
||||
)
|
||||
|
||||
def test_convert_eval_set_to_pydanctic_schema_minimal(self):
|
||||
def test_convert_eval_set_to_pydantic_schema_minimal(self):
|
||||
eval_set_id = "test_eval_set"
|
||||
eval_set_in_json_format = [{
|
||||
"name": "minimal_case",
|
||||
"data": [{"query": "Hello", "reference": "World"}],
|
||||
}]
|
||||
|
||||
eval_set = convert_eval_set_to_pydanctic_schema(
|
||||
eval_set = convert_eval_set_to_pydantic_schema(
|
||||
eval_set_id, eval_set_in_json_format
|
||||
)
|
||||
|
||||
@@ -117,7 +117,7 @@ class TestConvertEvalSetToPydancticSchema:
|
||||
== "World"
|
||||
)
|
||||
|
||||
def test_convert_eval_set_to_pydanctic_schema_empty_tool_use_and_intermediate_responses(
|
||||
def test_convert_eval_set_to_pydantic_schema_empty_tool_use_and_intermediate_responses(
|
||||
self,
|
||||
):
|
||||
eval_set_id = "test_eval_set"
|
||||
@@ -131,7 +131,7 @@ class TestConvertEvalSetToPydancticSchema:
|
||||
}],
|
||||
}]
|
||||
|
||||
eval_set = convert_eval_set_to_pydanctic_schema(
|
||||
eval_set = convert_eval_set_to_pydantic_schema(
|
||||
eval_set_id, eval_set_in_json_format
|
||||
)
|
||||
|
||||
@@ -150,7 +150,7 @@ class TestConvertEvalSetToPydancticSchema:
|
||||
== 0
|
||||
)
|
||||
|
||||
def test_convert_eval_set_to_pydanctic_schema_empty_initial_session(self):
|
||||
def test_convert_eval_set_to_pydantic_schema_empty_initial_session(self):
|
||||
eval_set_id = "test_eval_set"
|
||||
eval_set_in_json_format = [{
|
||||
"name": "empty_session",
|
||||
@@ -158,14 +158,14 @@ class TestConvertEvalSetToPydancticSchema:
|
||||
"initial_session": {},
|
||||
}]
|
||||
|
||||
eval_set = convert_eval_set_to_pydanctic_schema(
|
||||
eval_set = convert_eval_set_to_pydantic_schema(
|
||||
eval_set_id, eval_set_in_json_format
|
||||
)
|
||||
|
||||
assert eval_set.eval_set_id == eval_set_id
|
||||
assert eval_set.eval_cases[0].session_input is None
|
||||
|
||||
def test_convert_eval_set_to_pydanctic_schema_invalid_data(self):
|
||||
def test_convert_eval_set_to_pydantic_schema_invalid_data(self):
|
||||
# This test implicitly checks for potential validation errors during Pydantic
|
||||
# object creation
|
||||
eval_set_id = "test_eval_set"
|
||||
@@ -190,7 +190,7 @@ class TestConvertEvalSetToPydancticSchema:
|
||||
}]
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
convert_eval_set_to_pydanctic_schema(eval_set_id, eval_set_in_json_format)
|
||||
convert_eval_set_to_pydantic_schema(eval_set_id, eval_set_in_json_format)
|
||||
|
||||
|
||||
class TestLoadEvalSetFromFile:
|
||||
@@ -300,14 +300,14 @@ class TestLoadEvalSetFromFile:
|
||||
def test_load_eval_set_from_file_invalid_data(self, tmp_path, mocker):
|
||||
# Create a dummy file with invalid data that fails both Pydantic validation
|
||||
# and the old format conversion. We mock the
|
||||
# convert_eval_set_to_pydanctic_schema function to raise a ValueError
|
||||
# convert_eval_set_to_pydantic_schema function to raise a ValueError
|
||||
# so that we can assert that the exception is raised.
|
||||
file_path = tmp_path / "invalid_data.json"
|
||||
with open(file_path, "w", encoding="utf-8") as f:
|
||||
f.write('{"invalid": "data"}')
|
||||
|
||||
mocker.patch(
|
||||
"google.adk.evaluation.local_eval_sets_manager.convert_eval_set_to_pydanctic_schema",
|
||||
"google.adk.evaluation.local_eval_sets_manager.convert_eval_set_to_pydantic_schema",
|
||||
side_effect=ValueError(),
|
||||
)
|
||||
|
||||
@@ -392,7 +392,7 @@ class TestLocalEvalSetsManager:
|
||||
app_name = "test_app"
|
||||
eval_set_id = "invalid-id"
|
||||
|
||||
with pytest.raises(ValueError, match="Invalid Eval Set Id"):
|
||||
with pytest.raises(ValueError, match="Invalid Eval Set ID"):
|
||||
local_eval_sets_manager.create_eval_set(app_name, eval_set_id)
|
||||
|
||||
def test_local_eval_sets_manager_create_eval_set_already_exists(
|
||||
|
||||
@@ -182,7 +182,7 @@ def test_auto_to_auto_to_single(is_resumable: bool):
|
||||
]
|
||||
|
||||
# sub_agent_1 should still be the current agent. sub_agent_1_1 is single so
|
||||
# it should not be the current agent, otherwise the conversation will be
|
||||
# it should not be the current agent; otherwise, the conversation will be
|
||||
# tied to sub_agent_1_1 forever.
|
||||
assert testing_utils.simplify_events(runner.run('test2')) == [
|
||||
('sub_agent_1', 'response2'),
|
||||
|
||||
@@ -64,13 +64,13 @@ def test_sequential_calls():
|
||||
assert testing_utils.simplify_contents(mockModel.requests[0].contents) == [
|
||||
('user', 'test')
|
||||
]
|
||||
# 3 items: user content, functaion call / response for the 1st call
|
||||
# 3 items: user content, function call / response for the 1st call
|
||||
assert testing_utils.simplify_contents(mockModel.requests[1].contents) == [
|
||||
('user', 'test'),
|
||||
('model', function_call({'x': 1})),
|
||||
('user', function_response({'result': 2})),
|
||||
]
|
||||
# 5 items: user content, functaion call / response for two calls
|
||||
# 5 items: user content, function call / response for two calls
|
||||
assert testing_utils.simplify_contents(mockModel.requests[2].contents) == [
|
||||
('user', 'test'),
|
||||
('model', function_call({'x': 1})),
|
||||
@@ -78,7 +78,7 @@ def test_sequential_calls():
|
||||
('model', function_call({'x': 2})),
|
||||
('user', function_response({'result': 3})),
|
||||
]
|
||||
# 7 items: user content, functaion call / response for three calls
|
||||
# 7 items: user content, function call / response for three calls
|
||||
assert testing_utils.simplify_contents(mockModel.requests[3].contents) == [
|
||||
('user', 'test'),
|
||||
('model', function_call({'x': 1})),
|
||||
|
||||
@@ -32,7 +32,7 @@ def test_simple_function():
|
||||
function_call_1 = types.Part.from_function_call(
|
||||
name='increase_by_one', args={'x': 1}
|
||||
)
|
||||
function_respones_2 = types.Part.from_function_response(
|
||||
function_responses_2 = types.Part.from_function_response(
|
||||
name='increase_by_one', response={'result': 2}
|
||||
)
|
||||
responses: list[types.Content] = [
|
||||
@@ -54,7 +54,7 @@ def test_simple_function():
|
||||
runner = testing_utils.InMemoryRunner(agent)
|
||||
assert testing_utils.simplify_events(runner.run('test')) == [
|
||||
('root_agent', function_call_1),
|
||||
('root_agent', function_respones_2),
|
||||
('root_agent', function_responses_2),
|
||||
('root_agent', 'response1'),
|
||||
]
|
||||
|
||||
@@ -65,7 +65,7 @@ def test_simple_function():
|
||||
assert testing_utils.simplify_contents(mock_model.requests[1].contents) == [
|
||||
('user', 'test'),
|
||||
('model', function_call_1),
|
||||
('user', function_respones_2),
|
||||
('user', function_responses_2),
|
||||
]
|
||||
|
||||
# Asserts the function calls.
|
||||
|
||||
@@ -875,7 +875,7 @@ def test_execute_sql_non_select_stmt_write_protected_persistent_target(
|
||||
):
|
||||
"""Test execute_sql tool for non-SELECT query when writes are protected.
|
||||
|
||||
This is a special case when the destination table is a persistent/permananent
|
||||
This is a special case when the destination table is a persistent/permanent
|
||||
one and the protected write is enabled. In this case the operation should
|
||||
fail.
|
||||
"""
|
||||
|
||||
@@ -871,7 +871,7 @@ components:
|
||||
type: string
|
||||
iCalUID:
|
||||
description: |-
|
||||
Event unique identifier as defined in RFC5545. It is used to uniquely identify events accross calendaring systems and must be supplied when importing events via the import method.
|
||||
Event unique identifier as defined in RFC5545. It is used to uniquely identify events across calendaring systems and must be supplied when importing events via the import method.
|
||||
Note that the iCalUID and the id are not identical and only one of them should be supplied at event creation time. One difference in their semantics is that in recurring events, all occurrences of one event have different ids while they all share the same iCalUIDs. To retrieve an event using its iCalUID, call the events.list method using the iCalUID parameter. To retrieve an event using its id, call the events.get method.
|
||||
type: string
|
||||
id:
|
||||
|
||||
@@ -150,11 +150,11 @@ async def test_openid_connect_with_auth_response(
|
||||
tool_context = create_mock_tool_context()
|
||||
|
||||
mock_auth_handler = MagicMock()
|
||||
returned_credentail = AuthCredential(
|
||||
returned_credential = AuthCredential(
|
||||
auth_type=AuthCredentialTypes.OPEN_ID_CONNECT,
|
||||
oauth2=OAuth2Auth(auth_response_uri='test_auth_response_uri'),
|
||||
)
|
||||
mock_auth_handler.get_auth_response.return_value = returned_credentail
|
||||
mock_auth_handler.get_auth_response.return_value = returned_credential
|
||||
mock_auth_handler_path = 'google.adk.tools.tool_context.AuthHandler'
|
||||
monkeypatch.setattr(
|
||||
mock_auth_handler_path, lambda *args, **kwargs: mock_auth_handler
|
||||
@@ -176,7 +176,7 @@ async def test_openid_connect_with_auth_response(
|
||||
stored_credential = credential_store.get_credential(
|
||||
openid_connect_scheme, openid_connect_credential
|
||||
)
|
||||
assert stored_credential == returned_credentail
|
||||
assert stored_credential == returned_credential
|
||||
mock_auth_handler.get_auth_response.assert_called_once()
|
||||
|
||||
|
||||
|
||||
@@ -390,7 +390,7 @@ def test_function_regular_return_type_vertex_ai():
|
||||
assert function_decl.response.type == types.Type.STRING
|
||||
|
||||
|
||||
def test_fucntion_with_no_response_annotations():
|
||||
def test_function_with_no_response_annotations():
|
||||
"""Test a function that has no response annotations."""
|
||||
|
||||
def transfer_to_agent(agent_name: str, tool_context: ToolContext):
|
||||
|
||||
@@ -93,6 +93,4 @@ async def test_process_llm_request_failure_with_multiple_tools_gemini_1_models()
|
||||
await tool.process_llm_request(
|
||||
tool_context=tool_context, llm_request=llm_request
|
||||
)
|
||||
assert 'can not be used with other tools in Gemini 1.x.' in str(
|
||||
exc_info.value
|
||||
)
|
||||
assert 'cannot be used with other tools in Gemini 1.x.' in str(exc_info.value)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user