Skip to content

Is it possible to use fields docstrings as descriptions? #169

Closed Answered by guillaume-alvarez
guillaume-alvarez asked this question in Q&A
Discussion options

You must be logged in to vote

I found the solution: pydantic/pydantic#10106

This was implemented in Pydantic 2.7 with the [use_attribute_docstrings] (https://docs.pydantic.dev/latest/api/config/#pydantic.config.ConfigDict.use_attribute_docstrings) configuration value.

This wasn't made opt-in for various reasons:

  • Backwards compatibility
  • Potential bad performance (we inspect the AST to extract those docstrings)
  • Potential limitations in very specific scenarios.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by guillaume-alvarez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant