Skip to content

Commit 24f6b5d

Browse files
committed
fix: Get type names in a py<310 compatible manner
1 parent f1591d1 commit 24f6b5d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/bids_validator/context_generator.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ def typespec_to_type(name: str, typespec: Dict[str, Any]):
8686
return type_, metadata
8787

8888

89+
def _type_name(tp: type) -> str:
90+
try:
91+
return tp.__name__
92+
except AttributeError:
93+
return str(tp)
94+
95+
8996
def create_attrs_class(
9097
class_name: str,
9198
properties: Dict[str, Any],
@@ -128,7 +135,12 @@ def create_attrs_class(
128135
Attributes
129136
----------
130137
"""
131-
+ '\n'.join([f'{k}: {v.type.__name__}' for k, v in attributes.items()]),
138+
+ '\n'.join(
139+
[
140+
f'{k}: {_type_name(v.type)}\n\t{v.metadata["description"]}'
141+
for k, v in attributes.items()
142+
]
143+
),
132144
},
133145
)
134146

0 commit comments

Comments
 (0)