File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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__ :
You can’t perform that action at this time.
0 commit comments