Skip to content

Commit ba3c4ea

Browse files
refactor: split cache except into separate TypeError and KeyError handlers
1 parent f9ce14c commit ba3c4ea

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/google/adk/tools/function_tool.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,11 @@ def _preprocess_args(
134134
try:
135135
try:
136136
adapter = self._type_adapter_cache[target_type]
137-
except (KeyError, TypeError):
137+
except TypeError:
138138
adapter = pydantic.TypeAdapter(target_type)
139-
try:
140-
self._type_adapter_cache[target_type] = adapter
141-
except TypeError:
142-
pass
139+
except KeyError:
140+
adapter = pydantic.TypeAdapter(target_type)
141+
self._type_adapter_cache[target_type] = adapter
143142
converted_args[param_name] = adapter.validate_python(
144143
args[param_name]
145144
)

0 commit comments

Comments
 (0)