File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ def _preprocess_args(
142142 if inspect .isclass (target_type ) and issubclass (
143143 target_type , pydantic .BaseModel
144144 ):
145- if args [param_name ] is None :
145+ if args [param_name ] is None and is_optional :
146146 continue
147147 if not isinstance (args [param_name ], target_type ):
148148 try :
@@ -173,10 +173,16 @@ def _preprocess_args(
173173 f"Parameter '{ param_name } ': expected type '{ target_type } ',"
174174 f' validation error: { e } '
175175 )
176- except (TypeError , NameError ):
176+ except (TypeError , NameError ) as e :
177177 # TypeAdapter could not handle this annotation (e.g. a forward
178- # reference string). Skip validation silently.
179- pass
178+ # reference string). Skip validation but log a warning.
179+ logger .warning (
180+ "Skipping validation for parameter '%s' due to unhandled"
181+ " annotation type '%s': %s" ,
182+ param_name ,
183+ target_type ,
184+ e ,
185+ )
180186
181187 return converted_args , validation_errors
182188
Original file line number Diff line number Diff line change @@ -155,10 +155,12 @@ def test_multiple_param_errors(self):
155155 args , errors = tool ._preprocess_args (
156156 {"name" : 123 , "count" : "not_a_number" , "flag" : "not_a_bool" }
157157 )
158- # name: int->str coercion might fail in strict, but lax mode might
159- # handle it. count: "not_a_number"->int will fail. flag: depends on
160- # pydantic behavior.
158+ # All three fail: pydantic rejects int->str, "not_a_number"->int,
159+ # and "not_a_bool"->bool.
160+ assert len (errors ) == 3
161+ assert any ("name" in e for e in errors )
161162 assert any ("count" in e for e in errors )
163+ assert any ("flag" in e for e in errors )
162164
163165
164166# --- run_async integration tests ---
You can’t perform that action at this time.
0 commit comments