Closed nagledb closed 1 year ago
@nagledb Thanks for raising this issue here! I can confirm, this is definitely a bug. This part of the code adjustments for pydantic v2 is actually the most shaky part, too. Hence, it is great to spot this bug early on.
Thanks to @jerryjiahaha who already provided a PR via #170 fixing the bug :-).
Expect this bug to be fixed within the next days.
@all-contributors please add @nagledb for bug
@mansenfranzen
I've put up a pull request to add @nagledb! :tada:
@all-contributors please add @jerryjiahaha for code
@mansenfranzen
I've put up a pull request to add @jerryjiahaha! :tada:
Bug is fixed a new version v2.0.1
can be installed via pip install "autodoc_pydantic>=2.0.1,<3.0"
.
I am receiving doc build failures when trying to use an enum in a pydantic model.
Repo:
from pydantic import BaseModel, ValidationError
class FruitEnum(str, Enum): pear = 'pear' banana = 'banana'
class ToolEnum(IntEnum): spanner = 1 wrench = 2
class CookingModel(BaseModel): fruit: FruitEnum = FruitEnum.pear tool: ToolEnum = ToolEnum.spanner
Exception occurred: File "/Users/nagledb/Library/Caches/pypoetry/virtualenvs/myproject-B9PtQW94-py3.8/lib/python3.8/site-packages/sphinxcontrib/autodoc_pydantic/inspection.py", line 195, in get_given_constraint_keys field_schemas = definition["schema"]["schema"]["fields"] KeyError: 'schema' The full traceback has been saved in /var/folders/kf/kxls27sn2_qcslc3nhgrg7j40000gq/T/sphinx-err-fv0oyxyr.log, if you want to report the issue to the developers. Please also report this if it was a user error, so that a better error message can be provided next time. A bug report can be filed in the tracker at https://github.com/sphinx-doc/sphinx/issues. Thanks! make: *** [html] Error 2
autodoc-pydantic==2.0.0 pydantic==2.1.0 pydantic-settings==2.0.2 pydantic_core==2.4.0 Sphinx==5.1.1 sphinxcontrib-applehelp==1.0.4 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==2.0.1 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.5