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
Duplicated field description when using Pydantic 2.7's use_attribute_docstrings setting #254
Comments
@Galarzaa90 Thanks for reporting this issue! Nice to see pydantic using the doc strings automatically as the field description. As a quick workaround to solve your current duplication, you can configure the docstring-policy to use the field description only. However, for future releases, it makes sense to automatically switch the |
Yeah, I upgraded as soon as I saw that feature! Yes, I think it should be automatic, when the model uses
|
I had to rethink the way we intended the future documentation behavior in case Hence, I added a check for duplicated content provided by the field's description and the field's doc string. If they are identical, it is shown only once. Before merging the related PR, it would be great if you could test the changed behavior. To do so, please install the current dev release in your doc-building-environment via |
@all-contributors please add @Galarzaa90 for bug |
I've put up a pull request to add @Galarzaa90! 🎉 |
@mansenfranzen I confirm this works, I removed |
Thx for testing! |
Pydantic 2.7 added a new attribute to
ModelConfig
that allows fields to get its description from the docstring (See pydantic/pydantic#6563)However, this results in a duplicate description shown in Sphinx:
Version Info:
Python 3.11
Pydantic 2.7.0
autodoc_pydantic 2.1.0
Sphinx 7.2.6 (7.3.1 is not working)
Examples
The text was updated successfully, but these errors were encountered: