You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: Cannot import mkdocstrings-python>=1.14.0 if Pydantic v1 is installed #240
Our project uses Pydantic v1 and our docs stopped building after mkdocstrings-python 1.14.0 was released. It seems that importing mkdocstrings_handlers.python doesn't work if Pydantic v1 is installed.
Traceback (most recent call last):
File "<string>", line 1, in <module>
import mkdocstrings_handlers.python
File "/tmp/venv/lib64/python3.13/site-packages/mkdocstrings_handlers/python/__init__.py", line 3, in <module>
from mkdocstrings_handlers.python.handler import get_handler
File "/tmp/venv/lib64/python3.13/site-packages/mkdocstrings_handlers/python/handler.py", line 30, in <module>
from mkdocstrings_handlers.python.config import PythonConfig, PythonOptions
File "/tmp/venv/lib64/python3.13/site-packages/mkdocstrings_handlers/python/config.py", line 71, in <module>
@dataclass(**_dataclass_options) # type: ignore[call-overload]
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "pydantic/dataclasses.py", line 231, in pydantic.dataclasses.dataclass.wrap
File "pydantic/dataclasses.py", line 354, in pydantic.dataclasses._add_pydantic_validation_attributes
File "pydantic/dataclasses.py", line 407, in pydantic.dataclasses.create_pydantic_model_from_dataclass
File "pydantic/main.py", line 1030, in pydantic.main.create_model
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 495, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 474, in pydantic.fields.ModelField._get_field_info
ValueError: cannot specify `Annotated` and value `Field`s together for 'ignore_init_summary'
Expected behavior
It would be great if mkdocstrings-python could support Pydantic v1 or at least ignore it, since the Pydantic dependency seems to be optional anyway.
Hi @jvstme, thanks for the fast report, and sorry for the inconvenience. I remember thinking this could cause issues, but had to forget about it 😵💫 Let me push a fix that checks Pydantic's version to deactivate the logic if it's v1.
Activity
pawamoy commentedon Feb 3, 2025
Hi @jvstme, thanks for the fast report, and sorry for the inconvenience. I remember thinking this could cause issues, but had to forget about it 😵💫 Let me push a fix that checks Pydantic's version to deactivate the logic if it's v1.
fix: Deactivate Pydantic logic if v1 is installed instead of v2
pawamoy commentedon Feb 3, 2025
Should be fixed in v1.14.2, let me know 🤞
jvstme commentedon Feb 3, 2025
@pawamoy, yes, 1.14.2 works for us. Thanks for the prompt resolution!
fix: Deactivate Pydantic logic if v1 is installed instead of v2