Skip to content

Commit

Permalink
Allow None when Any or object is in Union
Browse files Browse the repository at this point in the history
Resolves pydantic#3444
  • Loading branch information
tharradine committed Nov 25, 2021
1 parent 0f9d5fe commit 6ecbf1b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pydantic/fields.py
Expand Up @@ -563,10 +563,11 @@ def _type_analysis(self) -> None: # noqa: C901 (ignore complexity)
if is_union_origin(origin):
types_ = []
for type_ in get_args(self.type_):
if type_ is NoneType:
if type_ is NoneType or type_ is Any or type_ is object:
if self.required is Undefined:
self.required = False
self.allow_none = True
if type_ is NoneType:
continue
types_.append(type_)

Expand Down

0 comments on commit 6ecbf1b

Please sign in to comment.