@@ -454,32 +454,31 @@ def func_metadata(
454454 # structured_output=True still forces one.
455455 return FuncMetadata (arg_model = arguments_model )
456456
457- output_model , wrap_output = _create_output_model (original_annotation , return_type_expr , func .__name__ )
458-
459- if output_model is not None :
460- try :
457+ try :
458+ output_model , wrap_output = _create_output_model (original_annotation , return_type_expr , func .__name__ )
459+ if output_model is not None :
461460 # FuncMetadata builds the validator and schema on construction, so an unsupported return type
462461 # surfaces here, at registration, rather than on the first call.
463462 return FuncMetadata (arg_model = arguments_model , output_model = output_model , wrap_output = wrap_output )
464- except (
465- PydanticUserError ,
466- ForbiddenQualifier ,
467- NameError ,
468- TypeError ,
469- ValueError ,
470- pydantic_core .SchemaError ,
471- pydantic_core .ValidationError ,
472- ) as e :
473- # These are expected errors when a type can't be converted to a Pydantic schema
474- # PydanticUserError: When Pydantic can't handle the type (e.g. PydanticInvalidForJsonSchema);
475- # subclasses TypeError on pydantic <2.13 and RuntimeError on pydantic >=2.13
476- # ForbiddenQualifier, NameError: an invalid qualifier or unresolvable annotation on a TypedDict key,
477- # met while rebuilding a stdlib TypedDict below 3.12 (pydantic reports both as PydanticUserError)
478- # ValueError: When there are issues with the type definition (including our custom warnings);
479- # arrives wrapped in a ValidationError when raised during FuncMetadata construction
480- # SchemaError: When Pydantic can't build a schema
481- # ValidationError: When validation fails
482- logger .info (f"Cannot create schema for type { return_type_expr } in { func .__name__ } : { type (e ).__name__ } : { e } " )
463+ except (
464+ PydanticUserError ,
465+ ForbiddenQualifier ,
466+ NameError ,
467+ TypeError ,
468+ ValueError ,
469+ pydantic_core .SchemaError ,
470+ pydantic_core .ValidationError ,
471+ ) as e :
472+ # These are expected errors when a type can't be converted to a Pydantic schema
473+ # PydanticUserError: When Pydantic can't handle the type (e.g. PydanticInvalidForJsonSchema);
474+ # subclasses TypeError on pydantic <2.13 and RuntimeError on pydantic >=2.13
475+ # ForbiddenQualifier, NameError: an invalid qualifier or unresolvable annotation on a TypedDict key,
476+ # met while rebuilding a stdlib TypedDict below 3.12 (pydantic reports both as PydanticUserError)
477+ # ValueError: When there are issues with the type definition (including our custom warnings);
478+ # arrives wrapped in a ValidationError when raised during FuncMetadata construction
479+ # SchemaError: When Pydantic can't build a schema
480+ # ValidationError: When validation fails
481+ logger .info (f"Cannot create schema for type { return_type_expr } in { func .__name__ } : { type (e ).__name__ } : { e } " )
483482
484483 if structured_output is True :
485484 # Model creation failed or produced warnings - no structured output
0 commit comments