Skip to content

Commit

Permalink
avoid checking against annotated if it's None
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Feb 15, 2021
1 parent 50a6915 commit bc17abc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pydantic/fields.py
Expand Up @@ -343,7 +343,7 @@ def _get_field_info(
field_info_from_config = config.get_field_info(field_name)

field_info = None
if get_origin(annotation) is Annotated:
if Annotated and get_origin(annotation) is Annotated:
field_infos = [arg for arg in get_args(annotation)[1:] if isinstance(arg, FieldInfo)]
if len(field_infos) > 1:
raise ValueError(f'cannot specify multiple `Annotated` `Field`s for {field_name!r}')
Expand Down Expand Up @@ -497,7 +497,7 @@ def _type_analysis(self) -> None: # noqa: C901 (ignore complexity)
if isinstance(self.type_, type) and isinstance(None, self.type_):
self.allow_none = True
return
if origin is Annotated:
if Annotated and origin is Annotated:
self.type_ = get_args(self.type_)[0]
self._type_analysis()
return
Expand Down
2 changes: 1 addition & 1 deletion pydantic/schema.py
Expand Up @@ -944,7 +944,7 @@ def go(type_: Any) -> Type[Any]:
# forward refs cause infinite recursion below
return type_

if origin is Annotated:
if Annotated and origin is Annotated:
return go(args[0])
if origin is Union:
return Union[tuple(go(a) for a in args)] # type: ignore
Expand Down

0 comments on commit bc17abc

Please sign in to comment.