Skip to content

Commit e015c5b

Browse files
authored
Merge pull request #46 from DavidCEllis/fix_string_types
Evaluate string types before attempting to use them
2 parents 1494ac2 + f84d4d6 commit e015c5b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/ducktools/env/_sqlclasses.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,13 @@ def __init_subclass__(
168168
if not value.internal:
169169
valid_fields[name] = value
170170

171-
if value.type == list[str]:
171+
v_type = value.type
172+
if isinstance(v_type, str):
173+
v_type = eval(v_type)
174+
175+
if v_type == list[str]:
172176
split_columns.add(name)
173-
elif value.type is bool:
177+
elif v_type is bool:
174178
bools.add(name)
175179

176180
cls.VALID_FIELDS = valid_fields
@@ -207,7 +211,12 @@ def create_table(cls, con):
207211
sql_field_list = []
208212

209213
for name, field in cls.VALID_FIELDS.items():
210-
field_type = TYPE_MAP[field.type]
214+
t = field.type
215+
# __future__ annotations
216+
if isinstance(t, str):
217+
t = eval(t)
218+
219+
field_type = TYPE_MAP[t]
211220
if field.primary_key:
212221
constraint = " PRIMARY KEY"
213222
elif field.unique:

0 commit comments

Comments
 (0)