Skip to content

Support Pydantic v1 field metadata - #901

Open
cristianchiriac wants to merge 2 commits into
mitmproxy:mainfrom
cristianchiriac:fix/pydantic-v1-864
Open

cristianchiriac wants to merge 2 commits into
mitmproxy:mainfrom
cristianchiriac:fix/pydantic-v1-864

Conversation

@cristianchiriac

Copy link
Copy Markdown

Summary

pdoc assumes every Pydantic model exposes the v2 __pydantic_fields__ metadata. On Pydantic v1, rendering a model raises AttributeError. Read __fields__ when v2 metadata is absent, including field defaults and descriptions, while keeping the v2 computed-field path unchanged.

Fixes #864.

Tests

  • The new Pydantic v1 regression failed before the patch and passes afterward.
  • Independently rendered a model with Pydantic 1.10.24, the version in the issue.
  • Full suite: 369 passed, 8 skipped, 100% coverage on Python 3.12/Windows.
  • ruff check .: passed.
  • mypy pdoc test: two existing errors in unchanged test/testdata/misc_py313.py and pdoc/doc_ast.py on Python 3.12; no new errors from this change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pdoc is raising exception if using in project using pydantic v1

1 participant