Open jnicoulaud-ledger opened 2 months ago
Hi @jnicoulaud-ledger,
thanks for raising the issue here!
This looks like an awkward behavior. Could you please provide a minimal reproducible example including the code of the complete pydantic model, the pydantic version you're using and all non-default configurations (conf.py and directive options)? This will help reproduce the bug.
Hi, I have the same problem. Here is an example and versions of code I'm using:
from pydantic import BaseModel, Field
from pydantic.config import ConfigDict
class Example(BaseModel):
"""
Pointing offset script parameters
"""
model_config = ConfigDict(title="example")
version: Annotated[
str,
Field(
pattern=r"^[a-zA-Z0-9_\.-]+$",
default="0.1.1",
title="My example failing class",
description="autodoc_pydantic does not deal with regex correctly",
),
]
autodoc_pydantic==2.2.0 pydantic==2.9.2 python== 3.11.5
call in .rst .. autopydantic_settings:: mymodule.Example
In conf.py I just added the extension "sphinxcontrib.autodoc_pydantic"
, did not change anything else in the configuration.
When using this kind of types in models:
It looks like the generator does not properly escape the regex as needed: