File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -679,7 +679,7 @@ def get_pydantic_field_documentation(node: ObjectNode) -> Attribute:
679679 path = path ,
680680 file_path = node .file_path ,
681681 docstring = prop .field_info .description ,
682- attr_type = prop .type_ ,
682+ attr_type = prop .outer_type_ ,
683683 properties = properties ,
684684 )
685685
Original file line number Diff line number Diff line change 1+ from typing import Set
2+
13from pydantic import BaseModel , Field
24
35
@@ -6,3 +8,4 @@ class Person(BaseModel):
68
79 name : str = Field ("PersonA" , description = "The person's name" )
810 age : int = Field (18 , description = "The person's age which must be at minimum 18" )
11+ labels : Set [str ] = Field (set (), description = "Set of labels the person can be referred by" )
Original file line number Diff line number Diff line change 33import os
44import sys
55from pathlib import Path
6+ from typing import Set
67
78import pytest
89from marshmallow import fields
@@ -223,6 +224,10 @@ def test_loading_pydantic_model():
223224 assert age_attr .type == int
224225 assert age_attr .docstring == "The person's age which must be at minimum 18"
225226 assert "pydantic-field" in age_attr .properties
227+ labels_attr = next (attr for attr in obj .attributes if attr .name == "labels" )
228+ assert labels_attr .type == Set [str ]
229+ assert labels_attr .docstring == "Set of labels the person can be referred by"
230+ assert "pydantic-field" in labels_attr .properties
226231
227232
228233def test_loading_marshmallow_model ():
You can’t perform that action at this time.
0 commit comments