Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7351b12

Browse filesBrowse files
Konnor-YoungKonnor YoungRobertCraigie
authored
fix(pydantic v1): more robust ModelField.annotation check (#2163)
--------- Co-authored-by: Konnor Young <konnoryoung@ip-192-168-1-39.us-west-1.compute.internal> Co-authored-by: Robert Craigie <robert@craigie.dev>
1 parent 8cb8cfa commit 7351b12
Copy full SHA for 7351b12

File tree

1 file changed

+2
-2
lines changed
Filter options

1 file changed

+2
-2
lines changed

‎src/openai/_models.py

Copy file name to clipboardExpand all lines: src/openai/_models.py
+2-2Lines changed: 2 additions & 2 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.