-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model subclasses do not show superclass fields #32
Comments
@matutter Thanks for reporting the issue. I can reproduce what you've observed. By default, sphinx autodoc does not include any member (attributes or methods) from base classes. However, it has a directive option named tests.py from pydantic import BaseModel
class MyBase(BaseModel):
field_on_base: str
class MySubclass(MyBase):
field_on_subclass: str index.rst
Even though this might work for you already, it also reveals an incosistency in autodoc_pydantic. The fields list should be aligned with the members that get documented. In case Therefore, I suggest that field list and also its cousin the validator list should respect |
@matutter The current dev release now respects inherited members. It is aligned with the default sphinx autodoc behavior. Additionally, a section in the FAQ now describes how to display fields/validators from base classes (see here). Before merging the related PR, it would be great if you could test the bug fix on your site to confirm that my test case did indeed capture the incorrect behavior which you've encountered. To do so, please install the current dev release in your doc-building-environment via |
@mansenfranzen confirmed this produced the expected output. Inherited members are included when using the |
Closing this issue via #37 |
is it possible to set this operation inside the conf.py file? |
I cannot find a way to show all fields of a model if it subclasses another BaseModel.
When generate the model's docs with
autopydantic_model
bothfield_on_base
andfield_on_subclass
is shown in the field list however only the docstring offield_on_subclass
is shown.The text was updated successfully, but these errors were encountered: