Skip to content

Commit 6a2dfbb

Browse files
Konnor-YoungKonnor YoungRobertCraigie
authored andcommitted
fix(pydantic v1): more robust ModelField.annotation check (#2163)
--------- Co-authored-by: Konnor Young <[email protected]> Co-authored-by: Robert Craigie <[email protected]>
1 parent 7de6c5c commit 6a2dfbb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/openai/_models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any,
651651
# Note: if one variant defines an alias then they all should
652652
discriminator_alias = field_info.alias
653653

654-
if field_info.annotation and is_literal_type(field_info.annotation):
655-
for entry in get_args(field_info.annotation):
654+
if (annotation := getattr(field_info, 'annotation', None)) and is_literal_type(annotation):
655+
for entry in get_args(annotation):
656656
if isinstance(entry, str):
657657
mapping[entry] = variant
658658

0 commit comments

Comments
 (0)