Skip to content

Commit

Permalink
Minor simplification of values-gathering
Browse files Browse the repository at this point in the history
  • Loading branch information
David Montague committed Jul 15, 2019
1 parent a43c7dc commit 0fb7f23
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pydantic/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ def _populate_sub_fields(self) -> None: # noqa: C901 (ignore complexity)
# python 3.7 only, Pattern is a typing object but without sub fields
return
if is_literal_type(self.type_):
if len(literal_values(self.type_)) > 1:
self.type_ = Union[tuple(Literal[value] for value in literal_values(self.type_))]
values = literal_values(self.type_)
if len(values) > 1:
self.type_ = Union[tuple(Literal[value] for value in values)]
else:
return
origin = getattr(self.type_, '__origin__', None)
Expand Down

0 comments on commit 0fb7f23

Please sign in to comment.