Skip to content

Commit 579eedd

Browse files
fix(pydantic v1): more robust ModelField.annotation check
1 parent 64f0107 commit 579eedd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/finch/_models.py

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

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

0 commit comments

Comments
 (0)