You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While I was trying to generate documentation with the autodoc extension I came into an issue for certain pydantic models. It looks like that under certain circumstances autodoc is interpreting the Annotated class to come from one of the project modules rather than the typing module.
To trigger the issue we need a project where:
there's an autoclass directive for a pydantic model
the model has an annotated field with BeforeValidator/AfterValidator
#src/example/models.pyfromtypingimportAnnotated, Anyimportpydanticfrom . importenumerationsdefvalidate(v: Any) ->Any:
""" This does nothing but triggers the error. """returnvclassCookingModel(pydantic.BaseModel):
fruit: Annotated[enumerations.FruitEnum, pydantic.BeforeValidator(validate)]
With this project structure I'm using a custom extension to find the pending_xref nodes and what I find out is a node with a reftarget equals to example.enumerations.Annotated which is unexpected.
How to Reproduce
I have created a small test repo to illustrate and reproduce the issue.
Describe the bug
While I was trying to generate documentation with the
autodoc
extension I came into an issue for certain pydantic models. It looks like that under certain circumstances autodoc is interpreting theAnnotated
class to come from one of the project modules rather than thetyping
module.To trigger the issue we need a project where:
BeforeValidator
/AfterValidator
With this project structure I'm using a custom extension to find the
pending_xref
nodes and what I find out is a node with areftarget
equals toexample.enumerations.Annotated
which is unexpected.How to Reproduce
I have created a small test repo to illustrate and reproduce the issue.
Environment Information
Sphinx extensions
Additional context
No response
The text was updated successfully, but these errors were encountered: