Browse Source
When a pydantic RootModel is parameterised with Annotated[SomeModel, Field(...)], pydantic stores the root field annotation verbatim as Annotated[SomeModel, FieldInfo(...)]. get_model_fields passed that annotation directly to lenient_issubclass, which returned False for the Annotated wrapper (it is not a type). This caused model_config to be forwarded to ModelField, which then passed it to TypeAdapter. Pydantic raises PydanticUserError when config is supplied together with a BaseModel/dataclass type. Fix: strip one level of Annotated wrapping before the issubclass check, using the public get_origin / get_args API from the standard typing module. Fixes #14805 (alternative to PR #14805 without private pydantic internals) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>pull/15115/head
2 changed files with 61 additions and 2 deletions
Loading…
Reference in new issue