-
-
Notifications
You must be signed in to change notification settings - Fork 210
feat: support Pydantic descriptions #855
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
base: main
Are you sure you want to change the base?
Conversation
pdoc/doc.py
Outdated
| elif _doc := _pydantic.get_computed_field_docstring( | ||
| cast(type, self.obj), | ||
| name, | ||
| ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to keep pydantic compexity out of pdoc.doc as much as possible. Can we please integrate this into get_field_docstring so that pdoc.doc remains pretty much unchanged? Computed fields are also still fields, so this is fine. :) Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely, I've moved it into get_field_docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks great except for the CI failures.
|
Should be all good now. There is a known issue with mypy when using the See here: https://docs.pydantic.dev/2.0/usage/computed_fields/ |
|
Just added a brief note in the docs regarding this addition :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Can you please add a CHANGELOG entry? Otherwise LGTM.
This PR should add support for Pydantic
computed_fielddescriptions.This is in addition to the current support for
Fielddescriptions, so it just allows for consistency when documenting Pydantic models.See issue #854
Let me know your thoughts !
Thanks again for the useful project :)