Skip to content

Commit d7bab54

Browse files
authored
🩹Fix _id docstring in coms in JSON-Schemas (#856)
1 parent 204032c commit d7bab54

2 files changed

Lines changed: 2 additions & 7 deletions

File tree

‎src/bo4e/com/com.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class COM(BaseModel):
5555
# an annotated version of Decimal, but you would have to use it everywhere in the pydantic models.
5656
# See this issue for more info: https://github.com/pydantic/pydantic/issues/6375
5757
json_encoders={Decimal: str},
58+
use_attribute_docstrings=True,
5859
)
5960
"""
6061
basic configuration for pydantic's behaviour

‎src/bo4e/utils/__init__.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ def add_comments_to_description(cls: type[T]) -> type[T]:
2828
# https://regex101.com/r/aJrvol/1
2929
regex_comment_inline = r"{field_name}:[^:]*#: ?(?P<comment>[^\n]*)\n"
3030
# https://regex101.com/r/0PaUmw/1
31-
regex_comment_below = r"{field_name}:[^:]*\n(?P<indent> +)\"{3}(?P<comment>(?:\"{0,2}[^\"])*)\"{3}"
32-
# https://regex101.com/r/9HhOlD/1
3331

3432
for field_name, field_info in cls.model_fields.items():
3533
if field_info.description is not None:
@@ -44,11 +42,7 @@ def add_comments_to_description(cls: type[T]) -> type[T]:
4442
if match is not None:
4543
field_info.description = match.group("comment").strip()
4644
continue
47-
# search for (multi line) comments below the field
48-
match = re.search(regex_comment_below.replace("{field_name}", field_name), fields_code)
49-
if match is not None:
50-
field_info.description = match.group("comment").strip().replace("\n" + match.group("indent"), "\n")
51-
continue
45+
# (multi line) comments below the field aka docstrings are now handled by pydantic
5246
# Try to find the comment in the bases
5347
description = None
5448
for base in cls.__bases__:

0 commit comments

Comments
 (0)