diff --git a/pydantic/fields.py b/pydantic/fields.py index 127f9cb1a8..ffbe903f4d 100644 --- a/pydantic/fields.py +++ b/pydantic/fields.py @@ -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}') @@ -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 diff --git a/pydantic/schema.py b/pydantic/schema.py index 2b68b89e54..f89e8681c7 100644 --- a/pydantic/schema.py +++ b/pydantic/schema.py @@ -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