Skip to content

Commit fe810b2

Browse files
fix(pydantic v1): more robust ModelField.annotation check
1 parent a423a7e commit fe810b2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/writerai/_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,8 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any,
627627
# Note: if one variant defines an alias then they all should
628628
discriminator_alias = field_info.alias
629629

630-
if field_info.annotation and is_literal_type(field_info.annotation):
631-
for entry in get_args(field_info.annotation):
630+
if (annotation := getattr(field_info, "annotation", None)) and is_literal_type(annotation):
631+
for entry in get_args(annotation):
632632
if isinstance(entry, str):
633633
mapping[entry] = variant
634634

0 commit comments

Comments
 (0)